Forum Moderators: coopster

Message Too Old, No Replies

Problem with Updating MYSQL

MySQL server version for the right syntax to use near

         

Twisted Mind

12:46 pm on Oct 12, 2005 (gmt 0)

10+ Year Member



Hi I joined this forum becouse i saw lots of great help and nice people while searching via google...

maybe you have seen this question before But when i send data to my MySQL database i get the following 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 yourtable.id= 100' at line 5

This is a common error with mysql 4.1.* if you will google for it you will find hunderds of people who suffer under this.

This is the code which may has to be changed.
it would work on older versions of mysql but im not allowed to install:


//build and issue query
$sql ="UPDATE $table SET
order_status_manager = ".$_POST['order_status_manager'].",
order_status_finance = ".$_POST['order_status_finance'].",
order_status_it = ".$_POST['order_status_it'].",
WHERE $table.order_id = ".$_POST['order_id']."";

$result = mysql_query($sql,$connection) or die(mysql_error());

I hope you guys can help me

arran

12:59 pm on Oct 12, 2005 (gmt 0)

10+ Year Member



Hi Twisted_Mind - welcome to webmasterworld.

You have an extra comma just before the 'WHERE'.

The code should read:


//build and issue query
$sql ="UPDATE $table SET
order_status_manager = ".$_POST['order_status_manager'].",
order_status_finance = ".$_POST['order_status_finance'].",
order_status_it = ".$_POST['order_status_it']."
WHERE $table.order_id = ".$_POST['order_id']."";

arran.

Twisted Mind

1:28 pm on Oct 12, 2005 (gmt 0)

10+ Year Member



Ill go try it if it works i love you

Twisted Mind

1:33 pm on Oct 12, 2005 (gmt 0)

10+ Year Member



I did do the changes but now the error sounds:
Unknown column 'Pending' in 'field list'
But Pending is one of the texts wich is going to be submitted and field list... i dont know...
what is this then?

Thanks for your help thats for the first time i get good help in a form :)

arran

2:08 pm on Oct 12, 2005 (gmt 0)

10+ Year Member



Remember, when you're updating String-type columns (e.g. char, varchar), you have to enclose the string in quotes.

Assuming all 3 fields (order_status_manager, order_status_finance and order_status_it but not order_id) are String fields, try:


//build and issue query
$sql ="UPDATE $table SET
order_status_manager = '".$_POST['order_status_manager']."',
order_status_finance = '".$_POST['order_status_finance']."',
order_status_it = '".$_POST['order_status_it']."'
WHERE $table.order_id = ".$_POST['order_id']."";

arran.

Twisted Mind

2:11 pm on Oct 12, 2005 (gmt 0)

10+ Year Member



k ill try

Twisted Mind

2:16 pm on Oct 12, 2005 (gmt 0)

10+ Year Member



Dude friends i love you you made it work i will stay on this form