开发者

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

开发者 https://www.devze.com 2023-03-13 18:20 出处:网络
I want to send a value of \"NULL\" to a column in mySQL. $ParentEv开发者_运维问答entID = \"NULL\";

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

   $ParentEv开发者_运维问答entID = "NULL";

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

The column keeps defaulting to "0". I have the column set to accept NULL and I can edit the cell with the NULL check box.

I need to not set the default to NULL because it may effect code in other places.


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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号