Good day,

I would have to dig around to find the appropriate note in the
documentation, however I seem to recall reading that PHP's MySQL wrappers
intentially prohibit a user from using semicolons- basically to prevent
one's database from being hacked due to a poorly constructed query using
user input.

I can't immediately find a reference to this, though.

As a workaround, you could execute two separate queries and store all of the
results in a 2-D array in memory.

Darren Gamble
Planner, Regional Services
Shaw Cablesystems GP
630 - 3rd Avenue SW
Calgary, Alberta, Canada
T2P 4L4
(403) 781-4948

-----Original Message-----
From: Jeff Bearer [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 25, 2002 8:34 AM
Subject: [PHP] using a mysql temporary table.


I'm trying to use a temporary table in mySQL with PHP.  First I tried to
create a temporary table and then query it in the same script. But the
table didn't persist to the second query in the PHP script. 

I found this knowledge base entry:

Where it shows to do all the querying in one swoop.  The problem I'm
having now is that PHP is throwing an error at the first semi-colon.  It
appears that it doesn't want to run multiple query statements in 1 query

I'm using the mySQL pear class in my application, I wouldn't think that
it would have any effect on the problem.

Here is an example of the query I'm attempting.

CREATE TEMPORARY TABLE tmp_events SELECT event_id, event_title FROM
events; INSERT INTO tmp_events SELECT event_id, event_title FROM
special_events; SELECT event_id, event_title FROM tmp_events ORDER BY

But I get an error like:
1064: You have an error in your SQL syntax near '; INSERT INTO

If I echo my SQL statement and paste it into mySQL the query works fine.
Any suggestions that you can offer would be great.

Jeff Bearer, RHCE
2002 EPpy Award, Best Online U.S. Newspaper

PHP General Mailing List (
To unsubscribe, visit:

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to