I must be stumped. I'm actually asking for Stack Overflow help.
PDO stuff:
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
I am using PHP 7.4 and MySQL 5.7.36 on WAMP Server to develop. I am getting the following error:
PDOStatement::errorInfo():
"Array ( [0] => 42000 [1] => 1064 [2] => 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 'CREATE TABLE `emailaddress` AS SELECT @seq := @seq + 1 as `rid`, `LastName`, `Fi' at line 1 )"
when creating and execution the following query from PHP/PDO:
SET @seq = 0;<br />
CREATE TABLE `emailaddress` AS SELECT @seq := @seq + 1 as `rid`, `LastName`, `FirstName`, `Email`
FROM `crew` WHERE `Status` = "A" AND `Approved` != "N" AND (`Email` IS NOT NULL OR `Email` != "");
When I cut and paste the identical query into PHPAdmin 5.2.0 it executes no problem?
PHP context:
$query = "SET @seq = 0; " .
"CREATE TABLE `emailaddress` AS SELECT @seq := @seq + 1 as `rid`, `LastName`, `FirstName`, `Email`" .
" FROM `crew` " .
'WHERE `Status` = "A" AND `Approved` != "N" AND (`Email` IS NOT NULL OR `Email` != "")';
...
try {
$result = $db->query($query);
}
catch (PDOException $e) {
LogError($e->getMessage());
echo "<br /><br />PDOStatement::errorInfo():<br /><br /><br />";
$arr = $db->errorInfo();
print_r($arr);
echo "<br /><br /><br />".$e;Exit;
...