<?php$conn = mysql_connect("localhost","root","1234567");
mysql_query("SET NAMES 'utf8'");
if (!$conn)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("code", $conn); $sql="INSERT INTO keycode (key) VALUES ('$_POST[username]')";
if($_POST[username]!=null){
mysql_query($sql, $conn);
echo "status='$_POST[username]'";
}else
echo "no number!";
mysql_close();
?>在flex端发送了一个参数过来,可为何插入不了的呢???
可以显示 echo "status='$_POST[username]'"; 这个,可是数据库里就是没看到有东西插入!!!!
各位高手,指点指点啊!!!!!
mysql_query("SET NAMES 'utf8'");
if (!$conn)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("code", $conn); $sql="INSERT INTO keycode (key) VALUES ('$_POST[username]')";
if($_POST[username]!=null){
mysql_query($sql, $conn);
echo "status='$_POST[username]'";
}else
echo "no number!";
mysql_close();
?>在flex端发送了一个参数过来,可为何插入不了的呢???
可以显示 echo "status='$_POST[username]'"; 这个,可是数据库里就是没看到有东西插入!!!!
各位高手,指点指点啊!!!!!
我把那个$sql 输出来是这样子的:INSERT INTO keycode (key) VALUES ('17')
然后我把它直接在mysql里运行提示说:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key) VALUES ('17')' at line 1这个语句语法真有错误吗?我用的是5.5.16的mysql??
key 是 mysql 保留字,挪作他用时要转义 $sql="INSERT INTO keycode (`key`) VALUES ('$_POST[username]')";
就解决了……看来,我来迟了……