Unable to Insert Twilio Message Received Date/Time into MYSQL DB Table

92 views Asked by At

The field name is msg_received and the data type is DATETIME

When a Twilio sms message is received, the msg_received field is populated with 0000-00-00 00:00:00

Being a complete newbie, I thought I got pretty far, but I am nit understanding this.

<?php
header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";

$MsgSid = $_REQUEST['MessageSid'];
$SmsSid = $_REQUEST['SmsSid'];
$MsgFrom = $_REQUEST['From'];
$MsgBody = $_REQUEST['Body'];

$host="localhost"; // Host name 
$username="xxxxxxxx"; // Mysql username 
$password="xxxxxxx"; // Mysql password 
$db_name="xxxxxxx"; // Database name 
$tbl_name="xxxxxxx"; // Table name

mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

$sql="INSERT INTO $tbl_name (msg_received, msg_MessageSid, msg_SmsSid, msg_From, msg_Body) VALUES ('CURRENT-TIMESTAMP', '$MsgRecd', '$MsgSid', '$SmsSid', '$MsgFrom', '$MsgBody')";
$result=mysql_query($sql);
?>
0

There are 0 answers