Jump to content

[SOLVED] mysql_real_escape_string functionality not working?


Recommended Posts

i have an about value that is posted.

 

when i capture it i escape it like so:

 

$iabout = mysql_real_escape_string(stripslashes($_POST['about']));

 

Lets say the value is:

 

I love "money"  and '''single quotes'''!!!x00

 

but when I look in the database

 

the value is still

 

I love "money"  and '''single quotes'''!!!x00

 

shouldnt it be now

 

 

I love \"money\"  and \'\'\'single quotes\'\'\'!!!\x00

 

since I used mysql_real_escape_string?

mysql_real_escape_string() only protects against sql injection when used on string data put into a query (data that is enclosed in single-quotes inside the query.)

 

It does not protect against sql injection on numeric data put into a query (data that is not be enclosed in single-quotes inside the query), such as an id field. For numeric data in a query, you either need to validate that it is numeric or cast it as a numeric data type in order to protect against sql injection.

It does, but then it must go through the step of converting that string containing numeric digits into a numeric value (if I remember correctly it converts to a floating point data type) and that would also require that everyone actually write queries with single-quotes in things like: WHERE id = $id

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.