ini_set('display_errors','Off'); error_reporting(0); mb_internal_encoding("UTF-8"); ini_set('auto_detect_line_endings', 1); date_default_timezone_set('Europe/Athens'); test_db_connect() or die ("Δεν είναι δυνατή η σύνδεση με τον διακομιστή, παρακαλώ ξανά δοκιμάστε σε άλλη στιγμή. <br /> Cannot connect to server, Please try again at another time.<br /> \n"); mysql_query("SET NAMES 'UTF8'"); mysql_query("SET CHARACTER SET 'utf8'"); print "<form action=".$_SERVER['PHP_SELF']." method=\"post\">\n"; print "<td>\n"; print "<input name=\"title\" size=\"60\" maxlength=\"200\"><br />\n"; print "</td>\n"; print "</tr><tr>\n"; print "<td colspan=\"2\"> </td>\n"; // <hr>draw line print "</tr><tr>\n"; print "<td colspan=\"2\" align=\"center\">\n"; print "<input type=\"submit\" name=\"phrase\" value=\"- Search -\" />"; // INPUT ERROR CHECKING BEGINS HERE // alternate through variables, check for empty, validate //----------------------------------------------------------------------- if (!get_magic_quotes_gpc()) { foreach ($_POST as $key => $value) { // Assign to $temp and trim spaces if not array $_POST[$value] = is_array($value) ? $value : addslashes(trim($value)); } // end foreach } else { foreach ($_POST as $key => $value) { // Assign to $temp and trim spaces if not array $_POST[$value] = is_array($value) ? $value : trim($value); } // end foreach } // end if (!get_magic_quotes_gpc //This stops SQL Injection in POST vars foreach ($_POST as $key => $value) { $_POST[$key] = mysql_real_escape_string($value); } //This stops SQL Injection in GET vars foreach ($_GET as $key => $value) { $_GET[$key] = mysql_real_escape_string($value); } $keyword = $_POST['title']; if (empty($keyword)) { print "<br />\n"; print "<div align='center' class='red'>"; print "No keyword was entered to search for a book!"; print "<br /><br />\n"; gobackpage(); print "</div>"; print "<br /><br />\n"; die; ?> </body> </html> <? die; } // regular search $select = "SELECT * FROM $db_name.$table_name WHERE ( subject LIKE '%$keyword%' OR author LIKE '%$keyword%' OR isbn LIKE '%$keyword%' OR city LIKE '%$keyword%' OR title LIKE '%$keyword%' OR owner LIKE '%$keyword%' )"; $result = mysql_query($select) or die($errorinfo); // display record disp_recs();
I suddenly realized that I forgot to check the database.Solved!