求大侠指点一下,插入变量的方法!解决方案

WBOY
Release: 2016-06-13 13:30:59
Original
687 people have browsed it

求大侠指点一下,插入变量的方法!
$name=$_POST["username"];
$psw=$_POST["userpsw"];
$email=$_POST["email"];
$qq=$_POST["qq"];
echo $name;
echo $psw;
echo $email;
echo $qq;
$insert=mysql_query("insert into user (name,psw,email,qq) values ($name,$psw,$email,$qq)");
if(!$insert){
echo "插入失败!";
}
?>
上述代码是执行一个表单提交信息的插入操作。
echo $name;
echo $psw;
echo $email;
echo $qq;
这段能输出,也就是说表单提交的没有问题吧?但是插入操作一直都是失败的,在数据库中也没有数据插入,请问是哪里出得问题呢?(我是初学者,谢谢你们的知道啦~~分也不多,在线等答复ing!)

------解决方案--------------------
SQL将你的变量全部添加上''.如果数据表是int数值等类型的可以不需要添加.其他的都添加上''

$insert=mysql_query("insert into user (name,psw,email,qq) values ('$name','$psw','$email','$qq')");
------解决方案--------------------

探讨

数据库连接是正常的,因为我一直都用这个.conn连接数据库,省的一直要写。查询的时候是可以实现的。

------解决方案--------------------
将你的表结构发出来我看看. 编码是什么 把编码设置一致

------解决方案--------------------
探讨

怎么发图……好像是没有装控件还是怎么的。
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!