update in mysql_query sometime return null

后端 未结 2 565
挽巷
挽巷 2021-01-26 16:19

I use this code for update a record in mysql
This is my code:



        
2条回答
  •  萌比男神i
    2021-01-26 16:58

    If mysql_query returned NULL, then that would be a bug on PHP. How do you know that it is actually returning NULL?

    For update statements mysql_query should only return TRUE or FALSE. So your error checking code is fine. As to finding out what went wrong, you will have to call other function - mysql_error() would give you a blurb about what went wrong. So print the value of mysql_error() inside your false block. Like this:

     echo 'failed. SQL Err: '. mysql_error()
    

    Do that and you will probably get a clue to as to how 'record got updated, but return value is false'. It should not have happened.

提交回复
热议问题