RE: [PHP] using a mysql temporary table.

From: Date: Mon, 25 Feb 2002 15:45:18 +0000
Subject: RE: [PHP] using a mysql temporary table.
Groups: php.general 
Request: Send a blank email to php-general+get-86100@lists.php.net to get a copy of this message
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:jbearer@tribweb.com] Sent: Monday, February 25, 2002 8:34 AM To: php-general@lists.php.net Subject: [PHP] using a mysql temporary table. Hello, 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: http://www.faqts.com/knowledge_base/view.phtml/aid/445 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 function. 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 event_title; But I get an error like: 1064: You have an error in your SQL syntax near '; INSERT INTO tmp_events' 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 Webmaster PittsburghLIVE.com 2002 EPpy Award, Best Online U.S. Newspaper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#86100) next »