I'm very sad. I want to be able to insert single quotes in my database names - for example, O'Connor.
So, when pasting into a DB, I do:
$lname = mysql_real_escape_string($_POST['lname']);
And then I insert $ lname into the DB.
When it is in the database, it looks like O \ 'Connor.
So, if I were to recall this last name in my web application, I would have to use:
$lname = stripslashes($r["lname"]);
It all works fine. However, I have a search function that will search for names and display the results. When I search, I need to find O \ 'Connor to get any results.
You see, after searching, the text field automatically saves the value of what was simply distorted (using sessions). So my code is:
$search = mysql_real_escape_string($_GET['search']); $_SESSION['search'] = $search;
As I said, when searching, I should use "O \ Connor", and then after searching, the value in the text box becomes "O \\\\" Connor "
It was hard to figure it out. Does anyone know what I'm doing wrong? Thanks!
EDIT:
Here is my php5.ini file regarding magic quotes:
; Magic quotes ; ; Magic quotes for incoming GET/POST/Cookie data. magic_quotes_gpc = On ; Magic quotes for runtime-generated data, eg data from SQL, from exec(), etc. magic_quotes_runtime = Off ; Use Sybase-style magic quotes (escape ' with '' instead of \'). magic_quotes_sybase = Off
However, my site is hosted on GoDaddy, and I do not have permission to edit the file :(