I tried using PDO with two insert query and i get this error. I already check each of the query directly in mysql db and its working perfectly. i'm not sure what is wrong with my code
<?php
define('MYSQL_USER', 'root');
define('MYSQL_PASSWORD', '');
define('MYSQL_HOST', 'localhost');
define('MYSQL_DATABASE', 'mydb');
$pdoOptions = array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_EMULATE_PREPARES => false
);
$pdo = new PDO(
"mysql:host=" . MYSQL_HOST . ";dbname=" . MYSQL_DATABASE, //DSN
MYSQL_USER, //Username
MYSQL_PASSWORD, //Password
$pdoOptions //Options
);
$sql = "INSERT INTO customer (cust_name) VALUES (:cust_name); ";
$sql .= "INSERT INTO reference (ref_name) VALUES (:ref_name) ";
$stmt = $pdo->prepare($sql);
$stmt->bindParam(':cust_name' , "test");
$stmt->bindParam(':ref_name' , "help");
if ($stmt) {
echo "Success";
} else {
print_r($stmt->errorInfo());
}
?>
this is the error that i get
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'INSERT INTO reference (ref_name) VALUES (?)' at line 1'