Jump to content

something wrong with my SQL statement?


boo_lolly

Recommended Posts

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

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!
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.
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?

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.