Re: Working query not able to run with PHP script.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Try putting backticks around the table name in the drop table statement. 

Is xxx the database name? 

-Micah

On Thu September 18 2003 2:09 pm, Jonathan Villa wrote:
> I have several tables I want to delete as well as their reference in
> another database
>
> The query produced is this:
> ===========================================================================
> DROP TABLE xxx.zorder_47629403705b7e7f0c97387559d8c811; DELETE FROM
> orders WHERE table_name = "zorder_47629403705b7e7f0c97387559d8c811";
> DROP TABLE xxx.zorder_17d991f48de0fdd157c31e77780d919e; DELETE FROM
> orders WHERE table_name = "zorder_17d991f48de0fdd157c31e77780d919e";
> DROP TABLE xxx.zorder_b2709995c3d487b7e19e878ccbbd19cd; DELETE FROM
> orders WHERE table_name = "zorder_b2709995c3d487b7e19e878ccbbd19cd";
> DROP TABLE xxx.zorder_7702fe78ee529c001ee989afc5471b94; DELETE FROM
> orders WHERE table_name = "zorder_7702fe78ee529c001ee989afc5471b94";
> DROP TABLE xxx.zorder_1b0ee4e8d5d556debe217074ccc62bbc; DELETE FROM
> orders WHERE table_name = "zorder_1b0ee4e8d5d556debe217074ccc62bbc";
> DROP TABLE xxx.zorder_d1d918c6231328c09dee573201e81102; DELETE FROM
> orders WHERE table_name = "zorder_d1d918c6231328c09dee573201e81102";
> DROP TABLE xxx.zorder_8d9f0fc5e5f4e64d1207063de7abcff1; DELETE FROM
> orders WHERE table_name = "zorder_8d9f0fc5e5f4e64d1207063de7abcff1";
> ===========================================================================
>
> If I run this query in PHPMyAdmin or MySQL CC, and echo out mysql_error
> I get the following 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 ';DELETE
> FROM orders WHERE table_name = "zorder_47629403705b7e7f
>
> Here is my script...
> $sql = 'SELECT table_name FROM orders WHERE completed = "0000-00-00
> 00:00:00"';
> $objRecordSet = new RecordSet($sql);
> $sql = '';
> while ($rows = mysql_fetch_array($objRecordSet->getResultID())) {
> //$sql .= ' DROP TABLE xxx.'.$rows['table_name'].';DELETE FROM orders
> WHERE table_name = "'.$rows['table_name'].'";';
> }
> $dbConn = mysql_connect("localhost", "root", "new-password");
> mysql_select_db("xxx", $dbConn);
> mysql_query($sql, $dbConn);
> echo "<br>".mysql_error();
>
> Any ideas

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux