I'm trying to execute a query in my cron job of drupal7. However something strange is happening. Every time it tries to execute I get an PDOException. When I paste the query in phpmyadmin there is no problem and the query executes. But iin my cronjob it gives the error. The problem is not in my cronjob, I know this because it also executes other queries without any problems.
The php code of the query:
$sql_insert_product = 'INSERT INTO tblProducten(productnummer, merk, doelgroep, RefLev)'
. 'VALUES(' . $prod->productnummer . ', "tt", "' . $prod->doelgroep . '", "'
. $prod->reflev . '")';
$db_catalogus->query($sql_insert_product);
The resulted query the code produces which works in phpmyadmin:
INSERT INTO tblProducten(productnummer, merk, doelgroep, RefLev) VALUES(16657, "tt", "Meisjes", "11803")
The Exception:
PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'tt' in 'field list': INSERT INTO tblProducten(productnummer, merk, doelgroep, RefLev) VALUES(16657, "tt", "Meisjes", "11803"); Array ( ) in cronner_cron() (line 94 of /home/...
$db_catalogus->query($sql_insert_product);
. Could you post it please ? – Frosty Z