944,179 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 2601
  • PHP RSS
Nov 16th, 2006
0

is there something wrong with my SQL statement?

Expand 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
php Syntax (Toggle Plain Text)
  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.  
Similar Threads
Reputation Points: 10
Solved Threads: 1
Light Poster
boo_lolly is offline Offline
35 posts
since Nov 2006
Nov 16th, 2006
0

Re: is there something wrong with my SQL statement?

You are missing a ')'

die(mysql_error())
Last edited by stymiee; Nov 16th, 2006 at 12:25 pm.
Moderator
Reputation Points: 161
Solved Threads: 38
He's No Good To Me Dead
stymiee is offline Offline
1,422 posts
since May 2006
Nov 16th, 2006
0

Re: is there something wrong with my SQL statement?

you're the man...
Click to Expand / Collapse  Quote originally posted by stymiee ...
You are missing a ')'

die(mysql_error())
Reputation Points: 10
Solved Threads: 1
Light Poster
boo_lolly is offline Offline
35 posts
since Nov 2006
Nov 16th, 2006
0

Re: is there something wrong with my SQL statement?

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.
Reputation Points: 10
Solved Threads: 1
Light Poster
boo_lolly is offline Offline
35 posts
since Nov 2006
Nov 16th, 2006
0

Re: is there something wrong with my SQL statement?

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.
Moderator
Reputation Points: 161
Solved Threads: 38
He's No Good To Me Dead
stymiee is offline Offline
1,422 posts
since May 2006
Nov 29th, 2006
0

Re: is there something wrong with my SQL statement?

Click to Expand / Collapse  Quote originally posted by boo_lolly ...
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
php Syntax (Toggle Plain Text)
  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?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
hazel_0821 is offline Offline
5 posts
since Nov 2006
Dec 2nd, 2006
0

Re: is there something wrong with my SQL statement?

The form may be on another page!

You can then use $_REQUEST['TBOXNAME']; to get the information.
Reputation Points: 15
Solved Threads: 17
Junior Poster
phper is offline Offline
189 posts
since Nov 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: view employee info for the employee selected from the drop down list
Next Thread in PHP Forum Timeline: Image link in an email from php





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC