Update query with syntax error

Reply

Join Date: Feb 2009
Posts: 12
Reputation: glycerine is an unknown quantity at this point 
Solved Threads: 1
glycerine glycerine is offline Offline
Newbie Poster

Update query with syntax error

 
1
  #1
Oct 13th, 2009
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

  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());
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 524
Reputation: Will Gresham is on a distinguished road 
Solved Threads: 86
Sponsor
Will Gresham's Avatar
Will Gresham Will Gresham is offline Offline
Posting Pro
 
0
  #2
Oct 13th, 2009
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.
AJAX is not a programming language, scripting language or any other sort of language.
It is acheived by using JavaScript http functions.
So, AJAX = JavaScript.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 12
Reputation: glycerine is an unknown quantity at this point 
Solved Threads: 1
glycerine glycerine is offline Offline
Newbie Poster
 
0
  #3
Oct 13th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 1,402
Reputation: ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light 
Solved Threads: 224
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey
 
1
  #4
Oct 13th, 2009
You have an extra , right before the WHERE
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 524
Reputation: Will Gresham is on a distinguished road 
Solved Threads: 86
Sponsor
Will Gresham's Avatar
Will Gresham Will Gresham is offline Offline
Posting Pro
 
0
  #5
Oct 13th, 2009
Originally Posted by ShawnCplus View Post
You have an extra , right before the WHERE
Good point, missed that one
AJAX is not a programming language, scripting language or any other sort of language.
It is acheived by using JavaScript http functions.
So, AJAX = JavaScript.
Reply With Quote Quick reply to this message  
Reply

Tags
error, syntax, update

Message:


Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC