note 52427 added to function.mysql-query

From: Date: Sat, 30 Apr 2005 23:21:48 +0000
Subject: note 52427 added to function.mysql-query
Groups: php.notes 
Request: Send a blank email to php-notes+get-88799@lists.php.net to get a copy of this message
The following query is not valid as expected: <?php $username = 'dicteworld'; $username{4} = ''; $sql = "SELECT * FROM user WHERE User = '$username'"; print($sql); // Result: SELECT * FROM user WHERE User = 'dictworld' $res = mysql_query($query); $row = mysql_fetch_array($res); print_r($row);// Result: still return Array(), supposed that the user 'dictworld' exists. ?> Pay more attention that null string '' is equivalent to '\0',therefore SQL statement above is equivalent to SELECT * FROM user WHERE User = 'dict\0world',though printing string is right. ---- Manual Page -- http://www.php.net/manual/en/function.mysql-query.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+52427 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52427&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52427&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52427&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52427&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52427&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+52427&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#88799) next »