November 16th, 2015, 04:04 PM
$variable with apostrophe problem
I am banging my head on this .
My script creates 2 files "first.php" and "second.php" and the content of the first file is "John" and the second file "Da'silva"
I am using these files throughout the script.
A folder of these 2 names joined together is also automatically created the folder name is "JohnDa'silva".
The script works perfect with all names without special characters.
$contenta = ob_get_contents();
$contentb = ob_get_contents();
The problem is when I use the following:
The script is having the single ' and double " conflicts. I have tried the backslach \' but the conflicts is still not ruled out. I also tried changing to " " but the conflicts ares till there. I need to have the last name available as is at all times. I do not want to remove the apostrophe in a name.
$result = "SELECT * FROM table where firstname='$contenta' AND lastname='$contentb' limit 1 ";
foreach ($conn->query($result) as $row)
echo ucfirst($row['firstname']) . ' ' . ucfirst($row['lastname']);
I would appreciate it very much if someone can perhaps point out to me what I am doing wrong or the solution to this conflict?
PS: these 2 names goes in the database as is.
Thank you very much in advance
Last edited by netfreak; November 16th, 2015 at 04:08 PM.
November 16th, 2015, 04:26 PM
There are 10 kinds of people in the world. Those that understand binary and those that don't.
November 16th, 2015, 04:56 PM
WoW! what do you know? Man, it worked like a charm... Thanks very much for the quick response and the solution. I tried almost everything except your solution. I feel like a dummy for not seeing/knowing that. Maybe I was too much inside that I FAIL to see the depth.
For those who may wonder what the solution is:
Once again, Thanks
$lastnamecfg = addslashes($contentb);
AND lastname= '$lastnamecfg'
Have a nice day...
Last edited by netfreak; November 16th, 2015 at 05:02 PM.