Reputation: 800
I have this SQL, made with MySQL Workbench: http://pastebin.com/T09Actyg
When executing the code manually in the MySQL console, everything works as expected. When querying from PHP however, I get this error:
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 'SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; SET @OLD' at line 2
This is essentially my PHP code:
$sql_conn = new mysqli($conf->sql_host, $conf->sql_user, $conf->sql_pass, $conf->db_name);
$query_str = file_get_contents("setup/sql_setup.txt");
$sql_conn->query($query_str);
I have no idea what's going on here. All help would be much appreciated.
EDIT: the content of the sql_setup.txt file is the pastebin I linked to.
Upvotes: 0
Views: 656
Reputation: 8004
mysqli::query
can only make one query at a time:
http://www.php.net/manual/en/mysqli.query.php
You could use mysqli::multi_query
instead:
http://www.php.net/manual/en/mysqli.multi-query.php
Upvotes: 2