From: d_sandlin at email dot com Operating system: Windows 8 PHP version: 5.4.16 Package: PHP options/info functions Bug Type: Bug Bug description:"\'" interpreted as "\'" instead of just '
Description: ------------ When I enter "INSERT INTO 'members' ('webmaster', 'abcd')" directly into phpMyAdmin, a record is added to table members with the appropriate values. I've tried several other variations and can't add the record with code. ---------------- Here is my .htaccess file: RemoveHandler .html .htm AddType application/x-httpd-php .php .htm .html ---------------- I had to add that to get php to work within an html file. My host is arvixe - Linux hosting Test script: --------------- \\(where $uname = "webmaster" and $pword = "abcd", and the $db_variables assigned \\ This is in an included file, db_connect.php 8 $mysqli = new mysqli($host, $db_username, $db_password, $db_name); 9 if ($mysqli->connect_errno) { 10 echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error; -------------------- } // This is where I'm having trouble: the "\'" characters aren't working as '. 22 $qtext = "INSERT INTO \'members\' (\'" . $uname . "\' , \'" . $pword . "\')"; 23 echo $qtext; 24 if (!$mysqli->query($qtext)) { 25 echo "Table insertion failed: (" . $mysqli->errno . ") " . $mysqli->error; 26 } Expected result: ---------------- I expect a record to be added to table 'members' with the following field values: (there are only 3 fields: id int(4)(autoincrement), username varchar(65), password varchar(65)) id = 6 (or some number), username = "webmaster", password = "abcd" Actual result: -------------- This from the echo $qtext, the if(), and the SQL server: INSERT INTO \'members\' (\'webmaster\' , \'abcd\')Table insertion failed: (1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\'members\' (\'webmaster\' , \'abcd\')' at line 1 ----------------- The backslash code is not translating special characters. "\'" should be interpreted as a single quote, but it isn't. -- Edit bug report at https://bugs.php.net/bug.php?id=65053&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=65053&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=65053&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=65053&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=65053&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=65053&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=65053&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=65053&r=needscript Try newer version: https://bugs.php.net/fix.php?id=65053&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=65053&r=support Expected behavior: https://bugs.php.net/fix.php?id=65053&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=65053&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=65053&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=65053&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65053&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=65053&r=dst IIS Stability: https://bugs.php.net/fix.php?id=65053&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=65053&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=65053&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=65053&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=65053&r=mysqlcfg