943,984 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1899
  • PHP RSS
Oct 13th, 2009
1

Update query with syntax error

Expand Post »
I have the following update code but i keep getting a syntax error.
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE order_id='105'' at line 21

PHP Syntax (Toggle Plain Text)
  1. mysql_query("UPDATE status SET
  2. id = '". $_POST['id'] ."',
  3. user_name = '". $_POST['user_name'] ."',
  4. to_serve_on = '". $_POST['to_serve_on'] ."',
  5. pri_address = '". $_POST['pri_address'] ."',
  6. sec_address = '". $_POST['sec_address'] ."',
  7. alt_address = '". $_POST['alt_address'] ."',
  8. home_tel = '". $_POST['home_tel'] ."',
  9. work_tel = '". $_POST['work_tel'] ."',
  10. cell_tel = '". $_POST['cell_tel'] ."',
  11. type_of_serve = '". $_POST['type_of_serve'] ."',
  12. doc_arrival = '". $_POST['doc_arrival'] ."',
  13. date_received = '". $_POST['date_received'] ."',
  14. court_name = '". $_POST['court_name'] ."',
  15. court_address = '". $_POST['court_address'] ."',
  16. case_number = '". $_POST['case_number'] ."',
  17. plaintiff = '". $_POST['plaintiff'] ."',
  18. defendant = '". $_POST['defendant'] ."',
  19. doc_order_notes = '". $_POST['doc_order_notes'] ."',
  20. progress = '". $_POST['progress'] ."',
  21. WHERE order_id='". $_POST['order_id'] ."'") or die(mysql_error());
Similar Threads
Reputation Points: 10
Solved Threads: 1
Newbie Poster
glycerine is offline Offline
17 posts
since Feb 2009
Oct 13th, 2009
0
Re: Update query with syntax error
Couple of things.

1. Why are you sending unchecked POST values to the database? That is just asking for trouble. Look at SQL injection.
Make sure that the values you receive are the ones you expected, that numbers are numbers etc...

2. Try running the query without single quotes on the numeric value.
Reputation Points: 96
Solved Threads: 124
Master Poster
Will Gresham is offline Offline
728 posts
since May 2008
Oct 13th, 2009
0
Re: Update query with syntax error
Hi xan we had sql injection in but we had simplified the query just to get it going first. Thanks i will look into you suggestion.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
glycerine is offline Offline
17 posts
since Feb 2009
Oct 13th, 2009
1
Re: Update query with syntax error
You have an extra , right before the WHERE
Sponsor
Reputation Points: 520
Solved Threads: 268
Code Monkey
ShawnCplus is offline Offline
1,564 posts
since Apr 2005
Oct 13th, 2009
0
Re: Update query with syntax error
Click to Expand / Collapse  Quote originally posted by ShawnCplus ...
You have an extra , right before the WHERE
Good point, missed that one
Reputation Points: 96
Solved Threads: 124
Master Poster
Will Gresham is offline Offline
728 posts
since May 2008

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: passing varaible between pages ussing sessions
Next Thread in PHP Forum Timeline: Display Php echo information on html pages





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


Follow us on Twitter


© 2011 DaniWeb® LLC