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
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!
Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.