unexpected error message in php form (SQL syntax error)

后端 未结 3 1909
野性不改
野性不改 2021-01-24 00:23

I have made a simple php cms form with database but it does not work properly when I want to submit the form with some dummy data! I don\'t know why it happens & also I adde

3条回答
  •  长发绾君心
    2021-01-24 01:08

    writing if statement in this way is better

    // this not always works
    if ($post_title=='' or $post_keywords='' or $post_content='' or $post_author=''){
            echo '';
        }
    
    // yeah much better 
     if (empty($post_title) || empty($post_keywords) || empty($post_content) || empty($post_author)){
                echo '';
            }
    

    and sql mistake most probably because of here

    '$post_keywords','$post_content')";
    

    $post_keywords and $post_content is null or empty

提交回复
热议问题