Jump to content

mysql_real_escape_string


lillyapps

Recommended Posts

Hello everyone.  This is my first post and I'm excited about using this forum.

 

So, what I'm trying to do is be pro-active in reguards to limiting SQL Injection with my new web application and learned that I should be using the mysql_real_escape_string() function.  What I belive is happening is that backslashes are being inserted for my quotes and apostrophes within my query string.  This sounds fine except for the SQL INSERTs and UPDATEs.  The backslashes are being included when writing to the database.

 

Example:  If I have a database field named myField and insert the string value: This is a "test" value

It is getting stored in my database as: This is a \"test\" value

 

I plan to do more testing tonight but thought I'd ask here first.

 

Thanks.

Link to comment
Share on other sites

rhodesa, it was Magic Quotes but I was looking in the wrong place.  When I escape a string in javascript and pass it, the _GET translates the HEX values (which I like) but it also inserts backslashes where ever there was a quote.  I added stripslashes() if Magic Quotes is ON when reading _GET and that fixed it.

 

Thanks for you help.

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.