为了账号安全,请及时绑定邮箱和手机立即绑定

我看代码都对啊,为什么会在修改文章的时候出现错误呢,

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 '' at line 1

<?php

header("Content-type:text/html;charset=UTF-8");

require_once('../connect.php');

//把传递过来的信息入库,在入库之前对搜有信息进行校验。

if(!(isset($_POST['title'])&&(!empty($_POST['title'])))){

echo "<script>alert('标题不能为空');window.location.href='article.add.php';</script>";

}

if(!(isset($_POST['author'])&&(!empty($_POST['author'])))){

echo "<script>alert('作者不能为空');window.location.href='article.add.php';</script>";

}

if(!(isset($_POST['description'])&&(!empty($_POST['description'])))){

echo "<script>alert('简介不能为空');window.location.href='article.add.php';</script>";

}

if(!(isset($_POST['content'])&&(!empty($_POST['content'])))){

echo "<script>alert('内容不能为空');window.location.href='article.add.php';</script>";

}

$id=$_POST['id'];

$title=$_POST['title'];

$author=$_POST['author'];

$description=$_POST['description'];

$content=$_POST['content'];

$dateline=time();

$insertsql="update article set title='$title',author='$author',description='$description',content='$content',dateline='$dateline' where id=$id";

if(mysql_query($insertsql)){

echo "<script>alert('文章修改成功');window.location.href='article.add.php';</script>";

}else{

echo '发布失败';

echo mysql_error();

}

?>

帮我看看吧,老师

正在回答

2 回答

dateline='$dateline',dateline不用''

0 回复 有任何疑惑可以回复我~
#1

月光下的人影 提问者

非常感谢!
2016-03-17 回复 有任何疑惑可以回复我~

$insertsql="update article set title='$title',author='$author',description='$description',content='$content',dateline='$dateline' where id=$id";   你的title='$title' 这样写不对的   你可以写成 $title 不需要加单引号,或者使用title='.$title.' 这种形式

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
PHP与MySQL关系大揭秘
  • 参与学习       72505    人
  • 解答问题       978    个

让我们一起走上探秘之旅,找寻php和mysql恋爱的真谛

进入课程

我看代码都对啊,为什么会在修改文章的时候出现错误呢,

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号