boo_lolly Posted November 16, 2006 Share Posted November 16, 2006 i don't see anything wrong with it... what's the deal? this is the results page that displays the results of a search query.[b]Parse error: parse error in ../../../../merchandise/testreg/results.php on line 21[/b][code=php] @ $db = mysql_connect("localhost", "apache", "R3GP@SS!"); if(!$db) { echo "Error: Could not connect to the database. Please try again later."; exit; } mysql_select_db("registry_DB, $db); $sql = mysql_query("SELECT brideLname, groomLname FROM my_search_table WHERE brideLname LIKE '%". $lname ."%' OR groomLname LIKE '%". $lname ."%'") or die(mysql_error();//<--- LINE 21 (entire SQL statement is on one line $result = mysql_query($sql); $num_result = mysql_num_rows($result); echo "Number of matches: ". $num_result ."<br />";[/code] Link to comment https://forums.phpfreaks.com/topic/27470-something-wrong-with-my-sql-statement/ Share on other sites More sharing options...
Psycho Posted November 16, 2006 Share Posted November 16, 2006 Ah yes, the "Parse Error"!Many, many times that indicates that the error is actually on an earlier line - it's just that the interpreter doesn't know theres a mistake until it gets to a later line.Look at the line before line 21:[code]mysql_select_db("registry_DB, $db);[/code]You have no closing quote for the database name! Link to comment https://forums.phpfreaks.com/topic/27470-something-wrong-with-my-sql-statement/#findComment-125597 Share on other sites More sharing options...
boo_lolly Posted November 16, 2006 Author Share Posted November 16, 2006 i'm an idiot. i'm sorry i waste bandwidth with simple errors like this. but that wasn't the problem. it still doesn't work. it still gives me the same error. but i believe you are right, the problem is probably not on line 21... but earlier. Link to comment https://forums.phpfreaks.com/topic/27470-something-wrong-with-my-sql-statement/#findComment-125599 Share on other sites More sharing options...
sford999 Posted November 16, 2006 Share Posted November 16, 2006 Look here[code]mysql_select_db("registry_DB, $db);[/code]It should be:[code]mysql_select_db("registry_DB", $db);[/code] Link to comment https://forums.phpfreaks.com/topic/27470-something-wrong-with-my-sql-statement/#findComment-125610 Share on other sites More sharing options...
boo_lolly Posted November 16, 2006 Author Share Posted November 16, 2006 THANKS. my 'or die' function was missing an extra ')' as well. thanks! Link to comment https://forums.phpfreaks.com/topic/27470-something-wrong-with-my-sql-statement/#findComment-125631 Share on other sites More sharing options...
boo_lolly Posted November 16, 2006 Author Share Posted November 16, 2006 the tables don't exist yet, but the database does... i get the following error when i click the submit button for a search. it seems to be combining my database name AND my table name....[b]Table 'registry_DB.my_search_table' doesn't exist[/b]my database name is 'registry_DB'. my table name is 'my_search_table'. what's the deal here? Link to comment https://forums.phpfreaks.com/topic/27470-something-wrong-with-my-sql-statement/#findComment-125638 Share on other sites More sharing options...
Psycho Posted November 16, 2006 Share Posted November 16, 2006 That is how it references a table - [i]DatabaseName.TableName[/i]Because you don't have the table yet it is generating an appropriate error message. Link to comment https://forums.phpfreaks.com/topic/27470-something-wrong-with-my-sql-statement/#findComment-125661 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.