I cannot get the code below to insert data.
<?php
$xml_gsm = null;
try {
// normally an include
$data = new PDO(MYSQL_DSN, MYSQL_USERNAME, MYSQL_PASSWORD);
$data->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
$stmt = $data->prepare("INSERT INTO tbl_sms_queue VALUES (fk_userId, fk_campaignId, message_content, gsm) VALUES (:userId, :campId, :message, :gsm);");
foreach($gsms as $number):
$xml_gsm .= "<gsm messageId='" . $data->lastInsertId() . "'>$number</gsm>";
$stmt->execute(array(':userId'=>$userId, ':campId'=>$campId, ':message'=>$message, ':gsm'=>$number));
print_r($data->errorInfo());
endforeach;
} catch(PDOException $e) {
echo $e->getMessage();
}
?>
PDO errorInfo reports 00000 but nothing is inserted, the user has full crud permissions, $gsms is an array of numbers.
I have looked at other answers and nothing applies, i am now stuck on this one and any help is appreciated.
Fixed:
I had:
instead of: