Home  >  Article  >  Backend Development  >  小弟我这段代码有什么错啊mysql_query不起作用也不报错的

小弟我这段代码有什么错啊mysql_query不起作用也不报错的

WBOY
WBOYOriginal
2016-06-13 10:12:071035browse

我这段代码有什么错啊,mysql_query不起作用也不报错的

include("in.php");
if (empty($_POST['YBT']))
{
mysql_close();
echo "<script>alert('非法提交!请重新提交!');history.back();</script>";
exit;
}
$YLX='展会资讯';
$exe="insert into yzx (YLX,YNR,YBT,YDT) values ('$YLX','".phpasp2($_POST["YNR"])."','".htmlencode2($_POST['YBT'])."','".time()."')";
$result=mysql_query($exe);
mysql_close();
echo "<script>alert('添加成功!');location.href='newslist.php';</script>";
exit;
?>

------解决方案--------------------
$result=mysql_query($exe) or die(mysql_error());

如有错误,请贴出。
------解决方案--------------------
那你可没设计好表,你想要自动增值,可是表却没有设置YID为自增

探讨

Field 'YID' doesn't have a default value. 可是我想要的事YID自动增值的呀

------解决方案--------------------
PHP code
//查看sql语句是否正确echo "sql-->>{$exe}<br>";if(mysql_affected_rows() > 0){ //若执行成功  echo "<script>alert('添加成功!');location.href='newslist.php';</script>";}else{  mysql_close();  echo "<script>alert('添加失败!');return;</script>";  exit;}mysql_close();<div class="clear">
                 
              
              
        
            </div>
Statement:
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