Jump to content

[SOLVED] mysql_real_escape_string functionality not working?


onedumbcoder

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.