Jump to content

Search Script.


Ruud Hermans

Recommended Posts

I managed to edit a searchscript I found online but for some reason I get a wierd output after processing it.This is the script:

<?include("config.php");//connect to mysql//change user and password to your mySQL name and passwordmysql_connect("localhost","$user","$password"); 	//select which database you want to editmysql_select_db("$database"); $search=$_POST["search"];//get the mysql and store them in $result//change whatevertable to the mysql table you're using//change whatevercolumn to the column in the table you want to search$result = mysql_query("SELECT * FROM news WHERE message LIKE '%$search%'");//grab all the contentwhile($r=mysql_fetch_array($result)){	   //the format is $variable = $r["nameofmysqlcolumn"];   //modify these to match your mysql table columns     $name=$r["name"];   $caliber=$r["caliber"];   $trigger_action=$r["trigger_action"];   $magazine_capacity=$r["magazine_capacity"];   $locktype=$r["locktype"];   $weight=$r["weight"];   $lenght=$r["lenght"];   $height=$r["height"];   $barrel_lenght=$r["barrel_lenght"];   $triggerstop=$r["triggerstop"];   $scope=$r["scope"];   $scope_lenght=$r["scope_lenght"];   $comments=$r["comments"];      //display the row   echo "$title <br> $name <br> $caliber <br> $trigger_action <br> $magazine_capacity <br> $locktype <br> $weight <br> $lenght <br> $height <br> $barrel_lenght <br> $triggerstop <br> $scope <br> $scope_lenght <br> $comments <br>";}?>

Now when I do a search I get the following result back:

$name$caliber$trigger_action$magazine_capacity$locktype$weight$lenght$height$barrel_lenght$triggerstop$scope$scope_lenght$comments"; } ?>
Anyone knows what is wrong here? :)
Link to comment
Share on other sites

What's the value of title? I don't see its declaration. Might it include any quote characters? SOMETHING is causing the end of your script to be echoed verbatim instead of quote-interpreted.
Sorry needed to delete the $title but forgot it, it has no value.I notest that the end is echoed of the script but I can't find any logical resaon why.
Link to comment
Share on other sites

You're just double-clicking on the PHP file, aren't you? If you open it in a browser and view the source code, do you see the complete PHP code? If you are running it normally, try changing the opening PHP tag to be the normal tag instead of the short tag.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...