html - PHP NULL vs 'NULL' -
this question came me spending 2 hours of trial , error , finding bug is, , need clarify why working way.
the code below prints out dropdown box default string being '--select status--' value of null.
print("<label>overall status overwrite:</label> <select name='case_ov_status' class='case_ov_status'> <option selected='selected' value=null>--select status--</option>");
on submit, call function determine whether dropdown box @ default value, if not update sql database. however, i'm confused. if statement below still run despite submitting value of null. found out 2 hours later using if($case_ov_status != 'null')
instead of if($case_ov_status != null)
solved problem.
if($case_ov_status != null){ //still ran despite != null. mysql_query("start transaction", $connection); $sql = "update cases set status=".$case_ov_status." patientid='".$patientid."' , caseid='".mysql_real_escape_string($case)."'"; $resultnew = mysql_query($sql, $connection);
this may sound basic, can explain how works? still learning.. in advance!
please read http://php.net/manual/en/language.types.null.php
null special value represent unallocated objects in php. "null" string literal containing word null , not same. in php may see type juggling equality. example, "" == null true.
you cannot send php null value on http since string in http. form though specify null value, send "null" server.
Comments
Post a Comment