Hopefully my question is relatively simple; I have a php maintenance page that runs a MySQL query. The query runs fine when run from php admin but when inserted in the php page it fails. Code as Follows;
<?php
$conn = mysql_connect ( "localhost", "username" , "password" );
mysql_select_db("inquiry", $conn);
$query = 'CREATE TEMPORARY TABLE tempinq SELECT id, max( follow_up_date ) AS date FROM inquirycomments GROUP BY id LIMIT 0 , 500; UPDATE inquiry INNER JOIN tempinq ON inquiry.ID = tempinq.ID SET inquiry.tickler_date = tempinq.date; ';
$res = mysql_query($query, $conn);
if ($res)
echo "success";
else {
die("Error while updating Inquiry table. Error Output: <br/>".
mysql_errno() . ": " . mysql_error(). "<br/>"."Query
follows:<br/>".$query);
return False;
}
?>
The Result output is;
Error while updating Inquiry table. Error Output:
1064: 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 '; UPDATE inquiry INNER JOIN tempinq ON inquiry.ID = tempinq.ID
Query follows:
CREATE TEMPORARY TABLE tempinq SELECT id, max( follow_up_date ) AS date FROM inquirycomments GROUP BY id LIMIT 0 , 500; UPDATE inquiry INNER JOIN tempinq ON inquiry.ID = tempinq.ID SET inquiry.tickler_date = tempinq.date;
I need guidance on the proper syntax to correct the error.
Thanks