我正在尝试将来自 Twilio 的短信中的内容插入 mysql。底部的响应正确返回,但数据未插入 mysql。我不确定我错过了什么。有什么帮助吗?
<?php
header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$From = $_REQUEST['From'];
$To = $_REQUEST['To'];
$Body = $_REQUEST['Body'];
$host="host"; // Host name
$username="user"; // Mysql username
$password="password"; // Mysql password
$db_name="database_name"; // Database name
$tbl_name="table"; // 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 (From, To, Body) VALUES ('$From', '$To', '$Body')";
$result=mysql_query($sql);
?>
<Response>
<Sms><?php echo $From ?> has messaged <?php echo $To ?> with the message of <?php echo $Body ?></Sms>
</Response>