I'm doing this to all strings before inserting them:
mysql_real_escape_string($_POST['position']);
How do I remove the: \ after retriving them?
So I don't end up with: \"Piza\"
Also is this enough security or should I do something else?
Thanks
I would suggest you call $_POST['position'] directly (don't call mysql_real_escape_string on it) to get the non-escaped version.
Incidentally your comment about security suggests a bit of trouble understanding things.
One way of handling strings is to handle the escaped versions, which leads to one kind of difficulty, while another is to handle another and escape strings just before embedding, which leads to another kind of difficulty. I much prefer the latter.
mysql_real_escape_string() does add \s in your SQL strings but they should not be making it into the database as they are only there for the purpose of string parsing.
If you are seeing \s in you database then something else is escaping your stings before you call mysql_real_escape_string(). Check to make sure that magic_quotes_gpc isn't turned on.
<?php phpinfo();?> and running it on your server will show all of your PHP settings. Search for "magic_quotes_gpc" without the quotes and you will see either "On" or "Off". This page will be a slight security hazard so delete it after you use it or give it a cryptic name.
PreparedStatementinstead ofmysql_real_escape_string().sql-injectionFAQs. Start with these: stackoverflow.com/questions/60174 stackoverflow.com/questions/110575 stackoverflow.com/questions/714704