Home > Backend Development > PHP Tutorial > 求教为什么小弟我的代码无法写入数据库

求教为什么小弟我的代码无法写入数据库

WBOY
Release: 2016-06-13 12:55:29
Original
951 people have browsed it

求教为什么我的代码无法写入数据库
我做了一个登记系统,有一个提交页面,从提交页面输入的信息,传到另一个PHP进行写入。但是不知道怎么,总是无法写入……


我的代码是
require_once("../config/config_database.php");
$name=$_POST['name'];
$cid=$_POST['cid'];
$xh=$POST['xh'];
$tel=$POST['tel'];
$bx=$POST['bx'];
$exec="insert into xx values($name,'$cid',$xh,'$tel',$bx)";

$result=mysql_query($exec);
if($result)
{
echo "您已登记成功";
}
else
{
echo"对不起,数据库写入失败,请重新登记!";
}
mysql_close();
?>


求大侠们赐教啊


------解决方案--------------------
$result=mysql_query($exec) or die(mysql_error());  //这样报错了没有
------解决方案--------------------
$exec="insert into xx(数据库中对应字段,不加引号) values('$name','$cid',$xh,'$tel','$bx')";
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