I have a problem in executing a query with MySQL and PHP. I connect to the database with PDO and when I run the query it returns the following errors:
errorCode = 42000
errorInfo = array ([0] => 00000 [1] => [2] =>)
After the modifications suggested, the code I use is this
require "connPDO.php";
ini_set('display_errors',1);
error_reporting(E_ALL);
$PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $PDO->prepare("INSERT INTO 'titacc' ('file', 'RGS', 'RGP', 'RGD', 'RGDG', 'RGOG', 'DenOrg', 'CodFiscOrg', 'TipoOrg', 'IntrTipoTass', 'IntrIncid', 'DenLocale', 'CodLocale', 'DataEv', 'OraEv',
'TipoGen', 'IncidGen', 'OrdPostoCodOrd', 'OrdPostoCapienza', 'TitoloEv', 'ProduttoreCinema', 'Autore', 'Esecutore', 'Nazionalita', 'Distributore', 'TATipoTit', 'TAQta',
'TACorrLordo', 'TAPrevendita', 'TAIVACorr', 'TAIVAPrev', 'TAImpPrest') VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?");
$stmt->execute(array(
$file,
$RGS,
$RGP,
$RGD,
$RGDG,
$RGOG,
$DenOrg,
$CodFiscOrg,
$TipoOrg,
$IntrTipoTass,
$IntrIncid,
$DenLocale,
$CodLocale,
$DataEv,
$OraEv,
$TipoGen,
$IncidGen,
$OrdPostoCodOrd,
$OrdPostoCapienza,
$TitoloEv,
$ProduttoreCinema,
$Autore,
$Esecutore,
$Nazionalita,
$Distributore,
$TATipoTit,
$TAQta,
$TACorrLordo,
$TAPrevendita,
$TAIVACorr,
$TAIVAPrev,
$TAImpPrest
));
if (! $stmt->exe1cute() )
{
echo "<b>Errore nella query!</b>"; echo"<br/>";
print_r($stmt->errorCode()); echo"<br/>";
print_r($stmt->errorInfo()); echo"<br/>";
print_r($PDO->errorInfo()); echo"<br/>";
die();
} else {
echo "<b>Inserimento avvenuto con successo</b>";
}
$PDO = null;
I read other posts and attempted to fix this, but the error remains. If the query is executed from the console, I have no error.