从mysql获取空白输出。从未使用"%s"之前

时间:2012-11-09 04:29:31

标签: php mysql insert

我的问题是我是否正确使用%s或者是否必须为我的变量使用其他内容? (我的数据库中没有添加任何记录)

参赛作品:

$login = "coolkidz";
$sname = "heyu";
$city = "beautiful";
$pass = "awesome";
$username = "what";
$mcode = "nice";

查询

mysql_query("INSERT INTO login(sname, city, pass, username, mcode, username) VALUES('%s','%s','%s','%s','%s','%s')", $sname, $city, $pass, $username, $mcode, $login);

这是不发光的回声

echo "'INSERT INTO login(sname, city, pass, username, mcode, username) VALUES('%s','%s','%s','%s','%s','%s')', $sname, $city, $pass, $username, $mcode, $login");

1 个答案:

答案 0 :(得分:1)

更改为:

mysql_query("INSERT INTO login(sname, city, pass, username, mcode, username) VALUES('$sname','$city','$pass','$username','$mcode','$login')");