Bug #25900 syntax error from PHP mysql_query but phpMyAdmin runs query OK
Submitted: 28 Jan 2007 22:54 Modified: 29 Jan 2007 15:18
Reporter: Randolph Lucas Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Parser Severity:S1 (Critical)
Version:5.0.24 standard OS:Linux (Linux )
Assigned to: CPU Architecture:Any
Tags: CREATE TABLE, temporary

[28 Jan 2007 22:54] Randolph Lucas
Description:
A syntax error is reported when running the query below using PHP MySQL mysql_query but runs without error via phpMyAdmin SQL interface.  The problem appears to be with CREATE and/or TEMPORARY keywords as I have many scripts which were successfully from the mysql_query function.

How to repeat:
CREATE TEMPORARY TABLE IF NOT EXISTS tmpz (TabID int,ParentId int); insert into tmpz (select 1,1); select * from tmpz;
[29 Jan 2007 10:01] Sveta Smirnova
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://dev.mysql.com/doc/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php

Please read carefull how C API function mysql_query works at http://dev.mysql.com/doc/refman/5.0/en/mysql-query.html Also read carefully PHP manual about MySQL extension
[29 Jan 2007 15:18] Randolph Lucas
I have been translating ASP SQL-Server apps to PHP MySQL. The ASP `execute` command to a ADODB.Connection handles multiple SQL statements in a single script.  It returns the LAST result set.  This is a nice feature and I was surprised to find that mysql_query cannot handle multiple statements at a time.  This issue should be dealt with as a new feature request.  Thanks.
[29 Jan 2007 15:37] Sveta Smirnova
Thank you for the additional comment.

C API function mysql_query can handle multiple SQL statements, so it can't be feature request here.

In PHP you can use mysqli functions instead of mysql to get access to mysqli_multi_query function.
[24 Aug 2010 19:42] Carl Liu
Thanks Randolph. I got the same problem and it turn out to be php-mysql does not support multiple statement.

Carl