I am trying to run multiple queries on some mysql dbs from a php file. However it is not working. Can anyone point out where I am going wrong?
Here is the contents of the php file:
<?
require_once('/home/xxxxxx/public_html/xxxxxx/dbconnect.php');
$query = "
TRUNCATE TABLE db2.table1;
INSERT INTO db2.table1
SELECT
column1, column2, column3, column4
FROM db1.table1;
TRUNCATE TABLE db2.table2;
INSERT INTO db2.table2
SELECT
column1, column2, column3, column4
FROM db1.table2;
ANALYZE TABLE db2.table2;
";
$result = @mysql_query($query);
?>
Thanks in advance for any help.
You are making only one query. Read docs for
mysql_queryYou should split each query in it’s own string and send it one by one to MySQL.
Or use some other interface function that supports multiple queries. Personally I don’t know if there is such a thing.