note 79255 added to function.mysql-query

From: Date: Sat, 17 Nov 2007 18:00:29 +0000
Subject: note 79255 added to function.mysql-query
Groups: php.notes 
Request: Send a blank email to php-notes+get-132373@lists.php.net to get a copy of this message
Keep in mind when dealing with PHP & MySQL that sending a null-terminated string to a MySQL query can be misleading if you use echo($sql) in PHP because the null terminator may not be visible. For example (this assumes connection is already made), $string1 = "mystring\0"; $string2 = "mystring"; $query1 = "SELECT * FROM table WHERE mystring='".$string1."'" $query2 = "SELECT * FROM table WHERE mystring='".$string2."'" $result1 = mysql_query($query1); $result2 = mysql_query($query2); //$result1 IS NOT EQUAL TO $result2 but will not provide an error //but printing these queries to the screen will provide the same result echo($result1); echo($result2); Not knowing this could lead to some mind-numbing troubleshooting when dealing with any strings with a null terminator. So now you know! :) ---- Server IP: 216.92.131.65 Probable Submitter: 69.133.90.74 ---- Manual Page -- http://www.php.net/manual/en/function.mysql-query.php Edit -- https://master.php.net/note/edit/79255 Del: integrated -- https://master.php.net/note/delete/79255/integrated Del: useless -- https://master.php.net/note/delete/79255/useless Del: bad code -- https://master.php.net/note/delete/79255/bad+code Del: spam -- https://master.php.net/note/delete/79255/spam Del: non-english -- https://master.php.net/note/delete/79255/non-english Del: in docs -- https://master.php.net/note/delete/79255/in+docs Del: other reasons-- https://master.php.net/note/delete/79255 Reject -- https://master.php.net/note/reject/79255 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#132373) next »