Jump to content

mysql_real_escape_string


c_pattle

Recommended Posts

I have a form that allows users to submit to a database and for security reasons I am using mysql_real_scape_string on all of their input values.  However this means that if the user puts something in speech marks such as

 

"hello"

 

It will then show up in the database as

 

\"hello\"

 

This means that whenever I fetch anything from the database it will have slashes in which doesn't look good.  How do other people get round this problem.  When I fetch something from my database should I do a string replace and just delete these slashes or is there a better method?

 

Thanks for any help. 

Link to comment
Share on other sites

 

 

Thanks, I don't think I'm escaping the fields twice.  I've copied below my code.  Am I escaping it twice?

 

$submit_sql = sprintf("insert into reviews (review_name, review_content, review_summary) values (\"%s\", \"%s\", \"%s\")", mysql_real_escape_string($_GET['submit_film_name']), mysql_real_escape_string($_GET['submit_film_content']), mysql_real_escape_string($_GET['submit_film_summary']));

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.