Hi everyone,
I'm trying to run a number of commands stored within a sql file from
within php using mysqli::query. The syntax I'm using is:
source C:\data\projects\forum
s\src/../tests_common/tableSnapshots/1_users.sql
The command works fine from the mysql command line client, but when I
try to run this with the mysqli query function, I get the following
error (echoed from the error property of the db object):
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 '\. C:\data
\projects\forum
s\src/../tests_common/tableSnapshots/1_users.sql' at line 1
Does anyone know if you can run the source command from within php? If
not, does anyone have any suggestions on how best to run a SQL file
created using MySQL Administrator from within PHP?
Thanks
Taras
$db = new mysqli('localhost','root','','devbb_testing',3306) ;
$result = $db->query('\. C:\data\projects\forums\src/../tests_common/
tableSnapshots/1_users.sql');
if($result === false)
{
echo "failed\n".$db->error.":".$db->errorno;
}
?>
Full source:
<?php
$db = new mysqli('localhost','root','','devbb_testing',3306) ;
$result = $db->query('\. C:\data\projects\forums\src/../tests_common/
tableSnapshots/1_users.sql');
if($result === false)
{
echo "failed\n".$db->error.":".$db->errorno;
}
?>