插入语句在PHP中失败

if(isset($_POST['title']) && isset($_POST['tag_h1']) && isset($_POST['tag_h2']) && isset($_POST['tag_metadata']) && isset($_POST['title']) && isset($_POST['postContent']))
{    
    $tag_h1=$_POST['tag_h1'];
    $tag_h2=$_POST['tag_h2'];
    $tag_metadata=$_POST['tag_metadata'];       
    $content=$_POST['postContent'];
    $title=$_POST['title'];
    $isTop=isset($_POST['isTop'])?1:0;
    $query = "INSERT INTO topic (tag_h1,tag_h2,tag_metadata,content,title,is_top) VALUES ('".$tag_h1."', '".$tag_h2."', '".$tag_metadata."', '".$content."', '".$title."'".$isTop."')";
    mysql_query($query) or die(mysql_error());
}

上述陈述失败。 抛出异常。 我看不到任何问题,导致Chrome死机..其他浏览器变空了......我看不到任何错误!

有谁知道为什么我的插入语句错了?

采纳答案:

有一个缺失:“,”和缺少“'”

$query = "INSERT INTO topic (tag_h1,tag_h2,tag_metadata,content,title,is_top) VALUES ('".$tag_h1."', '".$tag_h2."', '".$tag_metadata."', '".$content."', '".$title."'".$isTop."')";

介于'".$title."'".$isTop."'

应该:

$query = "INSERT INTO topic (tag_h1,tag_h2,tag_metadata,content,title,is_top) VALUES ('".$tag_h1."', '".$tag_h2."', '".$tag_metadata."', '".$content."', '".$title."', '".$isTop."')";
author: bassel-safadi

参考更多解答: Insert statement fails in PHP ,转载请保留出处插入语句在PHP中失败及作者信息

Statement: We respect knowledge and authors. Since the content comes from the Internet and is intended for scientific research, any reprinters should retain the author's signature and origin. If you are the author of the content and feel in dispute, please contact email: 1076545519@qq.com. We will find out the situation and deal with it in time. We sincerely thank the author for his hard work.


更多:mysql