检查与MySQL服务器版本对应的手册[重复]

This question is an exact duplicate of:

<?php include 'config.php';


    $user_id = 1;
    $postid = 9;
    $content = "sdfsdfsdfsdf";
    $date = '24';
    $category_id = 4;



$result = $db->query("INSERT INTO post_items(`post_id`,`content`,`date`,`user_id`,`category_id`) 
    VALUES ('".$postid.", '".$content."', '".$date."', '".$user_id."', '".$category_id."')");

if($result) { 
    echo "hey";
}else{
    echo $db->error;
}



?>

Please help, I've tried 3-4 hours but no luck.. I'm very sure all my column is correct, I'm so confused how to use sql syntax now, because I went to MySQL visual editor, it gave me different sql query for insert.

</div>

Missing the ' after $postId

VALUES ('".$postid.", '".$content."', '".$date."', '".$user
--------------------^
VALUES ('".$postid.", '".$con ...
        ^           ^^^

It appears that you have missed a single quote. It should be:

VALUES ('".$postid."', '".$con ...
                    ^
                 add this

This is yet another good reason (beyond the already excellent one of avoiding SQL injection attacks) that you should prefer parameterised queries. They're much more readable hence easier to debug.