How do you send NULL as a variable from PHP to SQL?

后端 未结 1 1235
离开以前
离开以前 2021-02-19 11:25

I want to send a value of \"NULL\" to a column in mySQL.

   $ParentEventID = \"NULL\";

   mysql_query(\"UPDATE events SET 
     ParentEventID = \'$ParentEventID         


        
1条回答
  •  长发绾君心
    2021-02-19 11:58

    You are on the right track making "NULL" a string. If you need to set it NULL, then remove the qoutes around $ParentEventID.

    mysql_query("UPDATE events SET ParentEventID = $ParentEventID");
    

    However, before doing so make sure that the value of $ParentEventID === NULL.

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