is there something wrong with my SQL statement?

Reply

Join Date: Nov 2006
Posts: 35
Reputation: boo_lolly is an unknown quantity at this point 
Solved Threads: 1
boo_lolly boo_lolly is offline Offline
Light Poster

is there something wrong with my SQL statement?

 
0
  #1
Nov 16th, 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.
Parse error: parse error in ../../../../merchandise/testreg/results.php on line 21
  1. @ $db = mysql_connect("localhost", "apache", "R3GP@SS!");
  2.  
  3. if(!$db)
  4. {
  5. echo "Error: Could not connect to the database. Please try again later.";
  6. exit;
  7. }
  8.  
  9. mysql_select_db("registry_DB, $db);
  10. $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
  11. $result = mysql_query($sql);
  12. $num_result = mysql_num_rows($result);
  13.  
  14.  
  15. echo "Number of matches: ". $num_result ."<br />";
  16.  
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,422
Reputation: stymiee is on a distinguished road 
Solved Threads: 35
Moderator
stymiee's Avatar
stymiee stymiee is offline Offline
He's No Good To Me Dead

Re: is there something wrong with my SQL statement?

 
0
  #2
Nov 16th, 2006
You are missing a ')'

die(mysql_error())
Last edited by stymiee; Nov 16th, 2006 at 12:25 pm.
John Conde
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 35
Reputation: boo_lolly is an unknown quantity at this point 
Solved Threads: 1
boo_lolly boo_lolly is offline Offline
Light Poster

Re: is there something wrong with my SQL statement?

 
0
  #3
Nov 16th, 2006
you're the man...
Originally Posted by stymiee View Post
You are missing a ')'

die(mysql_error())
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 35
Reputation: boo_lolly is an unknown quantity at this point 
Solved Threads: 1
boo_lolly boo_lolly is offline Offline
Light Poster

Re: is there something wrong with my SQL statement?

 
0
  #4
Nov 16th, 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....

Table 'registry_DB.my_search_table' doesn't exist


my database name is 'registry_DB'. my table name is 'my_search_table'. what's the deal here?
Last edited by boo_lolly; Nov 16th, 2006 at 1:49 pm.
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,422
Reputation: stymiee is on a distinguished road 
Solved Threads: 35
Moderator
stymiee's Avatar
stymiee stymiee is offline Offline
He's No Good To Me Dead

Re: is there something wrong with my SQL statement?

 
0
  #5
Nov 16th, 2006
That's just good error reporting. It helps that it is so specific as to avoid any confusion with similar table names in other databases.
John Conde
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 5
Reputation: hazel_0821 is an unknown quantity at this point 
Solved Threads: 0
hazel_0821 hazel_0821 is offline Offline
Newbie Poster

Re: is there something wrong with my SQL statement?

 
0
  #6
Nov 29th, 2006
Originally Posted by boo_lolly View Post
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.
Parse error: parse error in ../../../../merchandise/testreg/results.php on line 21
  1. @ $db = mysql_connect("localhost", "apache", "R3GP@SS!");
  2.  
  3. if(!$db)
  4. {
  5. echo "Error: Could not connect to the database. Please try again later.";
  6. exit;
  7. }
  8.  
  9. mysql_select_db("registry_DB, $db);
  10. $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
  11. $result = mysql_query($sql);
  12. $num_result = mysql_num_rows($result);
  13.  
  14.  
  15. echo "Number of matches: ". $num_result ."<br />";
  16.  
you have no text box... how would you search and your html form?
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 187
Reputation: phper is an unknown quantity at this point 
Solved Threads: 15
phper's Avatar
phper phper is offline Offline
Junior Poster

Re: is there something wrong with my SQL statement?

 
0
  #7
Dec 2nd, 2006
The form may be on another page!

You can then use $_REQUEST['TBOXNAME']; to get the information.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC