我有一个带有mysql后端的聊天应用程序。我正在尝试添加一行代码,以在完成房间更改功能后发布“ ...已加入房间”。
这是我的代码:
$PHP_PW = $_POST['password'];
$PHP_USER = $_POST['email'];
$PHP_ALIAS = $_POST['alias'];
$PHP_GENDER = $_POST['gender'];
$PHP_LON = $_POST['lon'];
$PHP_LAT = $_POST['lat'];
$PHP_STATUS = $_POST['status'];
$PHP_ROOM = $_POST['room'];
$PHP_ICON = $_POST['iconid'];
//$PHP_IP = $_SERVER['REMOTE_ADDR'];
$PHP_AGE = substr($_POST['age'],0,2);
$PHP_LOC = $_POST['location'];
$PHP_DOB = $_POST['dob'];
$PHP_IP = $_POST['device_id'];
if ($_POST['action']=="update")
{
if(!isset($PHP_USER))
{
echo "ERROR";
} else
{
if(isset($PHP_ROOM))
$update = mysql_query("UPDATE USER SET room='$PHP_ROOM',lastupdate=NOW() WHERE email='$PHP_USER'")or die("ERROR80");
$postmsg = mysql_query("INSERT INTO DATA (msgid,userid,date,message,room) VALUES (NULL,1,CURRENT_TIMESTAMP,'"...has joined the room"','$PHP_ROOM')") or die("ERROR1");
echo "OK 1";
}
mysql_close($db);
}
代码在没有
$postmsg = mysql_query("INSERT INTO DATA (msgid,userid,date,message,room) VALUES (NULL,1,CURRENT_TIMESTAMP,'"...has joined the"','$PHP_ROOM')") or die("ERROR1");
的情况下可以正常运行但是,如果我用$ postmsg行运行它,则不会得到错误和来自服务器的任何答复。
最佳答案
我认为问题出在$ postmsg "...has joined the room"
中。这不是连接字符串的正确方法
它应该是,'"."..has joined the room"."',
关于php - PHP脚本未运行或发布到mysql,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18393514/