Jump to content

Recommended Posts

function clean($input) {
	$input = @trim($input);
	if(get_magic_quotes_gpc()) {
		$input = stripslashes($input);
	}
	return mysql_real_escape_string($input);
}

 

i orginally had this function, shown above to clean up my inputs and prevent SQL injection. However, Magic_quotes_gpc is no longer supported. and this method although clear to me seems a little long winded!

 

is there an easier way for me to clean up my inputs thoroughly? and to avoid SQL injection

 

 

thanks

rob

Link to comment
https://forums.phpfreaks.com/topic/199714-sanitizing-function/
Share on other sites

since magic quotes is no longer supported, I suppose you could just get rid of the if statement. something like

function clean($var){
return mysql_real_escape_string(trim($var));
}

 

should suffice.

 

However, it may be a good idea to keep the if statement so your code is more portable. If you use that code on a server with php 4 or 5 (and magic quotes gpc is enabled) then it may not work as suspected.

 

 

Link to comment
https://forums.phpfreaks.com/topic/199714-sanitizing-function/#findComment-1048221
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.