![]() |
Magic Quotes
A real beginner question but i'm having difficulty with escaping input form data containing commas. Eg. Name entered as O'Neill. I'm checking magic quotes is switched off in th php.ini file which it is so i'm not stripping slashes from the input data. I am however using the mysql real_escape_string function on the data before adding it to the database. Its stored on the database as O'Neill and not O/'Neill however when i retrieve it using mysql SELECT statement the pho code is displaying it as O. Do i need to add a backslash to php knows its not the end of a string but actually part of the string?
Any general advice on this? Cheers. |
The problem i appear to be having is when i try and display the name as values in a form:
PHP Code:
|
I've fixed it by changing the ' to a ". I know the way php treats these is quite different. I assume it was treating it as a variable as opposed to a string. Not sure.
|
if you still want to use ' to delimit strings you can scape internal ' by escaping them with t backward slash \'
"" display the contents of variables if they are inside of strings like PHP Code:
|
If you aren't escaping the ' then the HTML becomes this:
HTML Code:
<input type='text' name='name' id='name' size='50' maxlength='50' value='O'Neil'>The fix would be to use addslashes in your form so that it escapes quotes. PHP Code:
HTML Code:
<input type='text' name='name' id='name' size='50' maxlength='50' value='O\'Neil'> |
| All times are GMT. The time now is 05:48 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0