Escaped data wont go into mysql

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Escaped data wont go into mysql

Postby shanetlbrt » 23. December 2011 21:02

When I insert data into my table, all the slashes get removed.

Look at this example to see what I mean:

Code: Select all
<?php
$db = //mysqli connection string here

$str = "this is' a string";
$str = mysqli_real_escape_string($db, $str);

echo $str; //outputs this is\' a string -- which is what should happen

mysqli_query($db, "INSERT INTO table (row) VALUES('$str')");
?>


Now the data is put into the database, but when I look, the "\" is removed. I've tried this with mysql and mysqli, same thing for both. Also did a fresh install of XAMPP.
shanetlbrt
 
Posts: 2
Joined: 23. December 2011 20:55
Operating System: Windows 7

Re: Escaped data wont go into mysql

Postby JonB » 26. December 2011 21:41

you do know slashes are escaped, right???
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Escaped data wont go into mysql

Postby shanetlbrt » 27. December 2011 20:49

Wait, what?
shanetlbrt
 
Posts: 2
Joined: 23. December 2011 20:55
Operating System: Windows 7


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 45 guests