rawky1976 Posted April 30, 2007 Share Posted April 30, 2007 I've taken this code from the web and modified it, I just get a blank space on the page where the results should be! <? $con = mysql_connect("localhost","somename","somepassword"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("somedatabase", $con); if ($search) // perform search only if a string was entered. { $srch="%".$search."%"; $query = "select * from document WHERE keywords LIKE '$srch'"; $result = mysql_db_query("somedatabase", $query); if ($result) { echo "Here are the results:<br><br>"; echo "<table width=90% align=center border=1><tr><td align=center bgcolor=#00FFFF>Document Name</td><td align=center bgcolor=#00FFFF>Keywords</td><td align=center bgcolor=#00FFFF>About</td></tr>"; while ($r = mysql_fetch_array($result)) { $dn = $r["document_name"]; $kw = $r["keywords"]; $abt = $r["about"]; echo "<tr><td>$dn</td><td>$kw</td><td>$abt</td></tr>"; } echo "</table>"; } else { echo "problems...."; } } else { echo "Search string is empty. <br> Go back and type a string to search"; } ?> Does anybody know why please? Link to comment https://forums.phpfreaks.com/topic/49293-solved-search-results-page/ Share on other sites More sharing options...
DaveEverFade Posted April 30, 2007 Share Posted April 30, 2007 try putting this at the top of your page: error_reporting(E_ALL); ini_set('display_errors', '1'); before you define $con. This may help diagnose the problem. I could be wrong here but should there not be a '@' before mysql_select_db? Link to comment https://forums.phpfreaks.com/topic/49293-solved-search-results-page/#findComment-241534 Share on other sites More sharing options...
rawky1976 Posted April 30, 2007 Author Share Posted April 30, 2007 I just noticed I forgot to add php after the <? !!! After trying your suggestion I now get: - Notice: Undefined variable: search in C:\Inetpub\wwwroot\searchResults.php on line 86 Search string is empty. Go back and type a string to search Link to comment https://forums.phpfreaks.com/topic/49293-solved-search-results-page/#findComment-241538 Share on other sites More sharing options...
rawky1976 Posted April 30, 2007 Author Share Posted April 30, 2007 It seems that it isn't getting the value of search variable from the previous page: - <form method="post" action="searchResults.php"> <br><input type=text name='search' size=60 maxlength=255> <br><br><br><input type=submit value="Search!"> Link to comment https://forums.phpfreaks.com/topic/49293-solved-search-results-page/#findComment-241539 Share on other sites More sharing options...
Psycho Posted April 30, 2007 Share Posted April 30, 2007 I just noticed I forgot to add php after the <? !!! After trying your suggestion I now get: - Notice: Undefined variable: search in C:\Inetpub\wwwroot\searchResults.php on line 86 Search string is empty. Go back and type a string to search You are not defining $search anywhere. The script was probably developed with REGISTER_GLOBALS enabled - which is a bad thing. You need to use $_POST['search'] instead. Link to comment https://forums.phpfreaks.com/topic/49293-solved-search-results-page/#findComment-241540 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.