debug mysqli query with or die mysqli_error

前端 未结 1 981
北海茫月
北海茫月 2021-01-26 02:22

I don\'t know what is wrong.

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


        
相关标签:
1条回答
  • 2021-01-26 02:37

    You have a problem with single quotes. You have a ' just before your $postid, but not one after. This means that the SQL query will be seeing '$postid, ' as your first variable and then being confused about the remained.

    Try changing your SQL to read:

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

    Hope that helps.

    0 讨论(0)
提交回复
热议问题