MYSQL IN A PHP LOOP
| From: | Malcolm JC Clark | Date: | Wed, 09 Nov 2005 18:12:11 +0000 |
| Subject: | MYSQL IN A PHP LOOP | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-40632@lists.php.net to get a copy of this message | ||
I have a php function that creates the following SQL below with this
statement in the loop:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$myQuery .= " UPDATE page SET
page_order_id = \"$page_order_id\"
WHERE page_id = \"$page_id\";
";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$myQuery looks finally like this:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
UPDATE page SET page_order_id = "3" WHERE page_id = "1"; UPDATE page SET
page_order_id = "5" WHERE page_id = "2"; UPDATE page SET page_order_id =
"2"
WHERE page_id = "3"; UPDATE page SET page_order_id = "5" WHERE page_id =
"4"; UPDATE page SET page_order_id = "6" WHERE page_id = "5"; UPDATE
page
SET page_order_id = "2" WHERE page_id = "13";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I get this (custom)error when the query is sent to mysql_query()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Err: You have an error in your SQL syntax near '; UPDATE page SET
page_order_id = "5" WHERE page_id = "2"' at line 4
Err No.:1064
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Stuck into PhpMyAdmin does not produce an error, and I know that there are
functions behind PhpMyAdmin that format user's SQL statements, and I wish I
knew how!!
It is maybe something to do with the semi-colons? Or that I can not normally
send several UPDATE statements in one query???
PLease help.
Malc
___ __ _ _ ____ ___
/ __) /__\ ( \/\/ )( _ \ / __)
\__ \ /(__)\ ) ( )(_) )\__ \
(___/(__)(__)(__/\__)(____/ (___/
Strategically Applied Web Development Systems
Contact: Malcolm JC Clark
Tel: 0161 408 2883
Mobile: 07779 034 868
This e-mail may contain confidential and/or privileged information. If you
are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail. Any
unauthorised copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.