PHP motore di ricerca nel sito

Stato
Chiusa ad ulteriori risposte.

lugalzaggesi

Nuovo Utente
1 Apr 2014
11
0
3
Ciao a tutti
Passando da Altervista ad Aruba ho notato che il codice di connessione non funziona.
Avete qualche dritta da darmi?
Non so dove sta l'errore /orrore.
Grazie Mille

Mirko


<?php $key = $_POST['key']; class Search { #CONFIGURA #Parametri ricerca var $fulltext = "year,siteno,name"; var $table = ""; #parametri db var $host = ""; var $password = ""; var $user = ""; var $db = ""; # var $pf = "f"; # # var $key; var $conn; var $res; var $total; function Search($key) { $this->key = $key; } function DbConnectAndSelect() { $db=new PDO('mysql:host=89.46.111.202;dbname=;charset=utf8', '', '') or die("Could connect to Database"); } function GetResource() { $this->DbConnectAndSelect(); $sql = "SELECT *, MATCH($this->fulltext) AGAINST('$this->key' IN BOOLEAN MODE) AS tot FROM $this->table WHERE MATCH($this->fulltext) AGAINST('$this->key' IN BOOLEAN MODE) ORDER BY tot DESC"; $this->res = mysql_query($sql, $this->conn); } function CalcScore($tot) { switch($this->pf) { case "f": $key_array = explode(" ", $this->key); $this->total = count($key_array); return $tot . " / " . $this->total; break; case "p": $key_array = explode(" ", $this->key); $this->total = count($key_array); $output = intval($tot / $this->total * 100) . "%"; return $output; break; default: $key_array = explode(" ", $this->key); $this->total = count($key_array); return $tot . " / " . $this->total; } } } $search = new Search($key); $search->GetResource(); $year=$row['year']; $siteno=$row['siteno']; $name=$row['name']; while ($row = mysql_fetch_array($search->res)) { echo "<div>"; echo "<br>"; echo "<font face=\"Arial\" size=\"2\">"; echo "<table width=\"640\" align=\"justify\" bgcolor=\"#FAFAD2\" cellpadding=\"3\" >"; echo "<tr>"; echo "<td>"; echo "<b>"; echo "Id:"; echo "</b>"; echo "&nbsp;"; echo $row['year']; echo "&nbsp;"; echo "&nbsp;"; echo "&nbsp;"; echo "&nbsp;"; echo "&nbsp;"; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td>"; echo "<b>"; echo "Author:"; echo "</b>"; echo "&nbsp;"; echo $row['siteno']; echo "&nbsp;"; echo "&nbsp;"; echo "<b>"; echo "</b>"; echo "&nbsp;"; echo "</div>"; } ?>
 
codice.JPG
 
Stato
Chiusa ad ulteriori risposte.

Discussioni simili