|
Posted by Oli Filth on 09/25/60 11:37
Tom said the following on 17/01/2006 03:27:
> I've used heredocs for single SQL statements without a problem. Also,
> I've tried this using the SQL form on PhpMyAdmin and it works so I
> conclude it should work in PHP.
>
> Problem: getting syntax error with following SQL statement:
>
> $_sql = <<<SQLDOC
> LOCK TABLES `table_name` WRITE;
> INSERT INTO `table_name` ('col_a', 'col_b') VALUES ('value_a1',
> 'value_a2');
> INSERT INTO `table_name` ('col_a', 'col_b') VALUES ('value_b1',
> 'value_b2');
> UNLOCK TABLES;
> SQLDOC;
>
> Error Message:
>
> "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 '; INSERT INTO `table_name`..."
>
mysql_query() doesn't support multiple SQL statements separated by
semi-colons. You'll either need to separate your statements into
separate mysql_query() calls, or use the mysqli_multi_query() statement,
if it's available.
--
Oli
Navigation:
[Reply to this message]
|