Jump to content

bypassing mysql_escape?


Monkuar

Recommended Posts

i use mysql escape and intval for my integers

 

but i read this article

 

http://www.itshacked.com/350/bypassing-php-security-mysql_escape_string-while-sql-injection-attacks-is-possible.html

 

shows that people can bypass t he mysql_escape, but that article is only showing if they dont intval there ID= XXXX

 

is it true or bogus?

 

what are some more security measures can I take to help reduce the risk of sql injection?

 

I use intval and mysql_escape_string, what else?

Link to comment
Share on other sites

Are you using mysql_escape_string(), which has been deprecated since php 4.3.0, or mysql_real_escape_string()? There's a difference, and you should be using the _real_ function.

 

im using

 

function escape($str)
{
	return is_array($str) ? '' : mysqli_real_escape_string($this->link_id, $str);
}

 

then I do $db->escape($variable) for whatever variable before enters db

 

good?

Link to comment
Share on other sites

For that part, yes. For numeric values, they need to be at the least cast as the appropriate data type. Validating them doesn't hurt either, so you can tell your user about any errors and let them correct mistakes.

 

Love it

 

thank you

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.