Edit report at https://bugs.php.net/bug.php?id=65053&edit=1
ID: 65053 Updated by: ahar...@php.net Reported by: d_sandlin at email dot com Summary: "\'" interpreted as "\'" instead of just ' -Status: Open +Status: Not a bug Type: Bug -Package: PHP options/info functions +Package: MySQL related Operating System: Windows 8 PHP Version: 5.4.16 Block user comment: N Private report: N New Comment: Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. Previous Comments: ------------------------------------------------------------------------ [2013-06-17 22:26:45] d_sandlin at email dot com 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 this bug report at https://bugs.php.net/bug.php?id=65053&edit=1