Jump to content

Recommended Posts

if you have to ask 'is it safe'  it probably isn't and in this case that is true.

 

escape ALL form generated input going into a database.  Doesn't matter if it comes from a text box or a select box or even a hidden field.  In fact, you have to escape it to allow single quotes, otherwise the query will break, regardless if it's intentional injection or not.

Link to comment
https://forums.phpfreaks.com/topic/114260-is-this-safe/#findComment-587520
Share on other sites

well technically the RISK factor has to do with wat exactly your building and WHO is going to be using it...

 

in your case.. it would be in your best interest to setup  escapes on your inputs.. because you do not know and will not really know the users on your site.. all it takes is one.

 

You can still allow them to enter code but just restrict what code they can enter.

Link to comment
https://forums.phpfreaks.com/topic/114260-is-this-safe/#findComment-587522
Share on other sites

you could just replace the single quotes with an ascii character and then do the mysql_real_escape_string()

I'm sure that would be safe and it would allow the single quote to be displayed

<?php
$string=str_replace("'", "&#39;",$string);
$string=mysql_real_escape_string($string);
?>

 

PS it should be just the 39 character but this forum messes it up somehow

Link to comment
https://forums.phpfreaks.com/topic/114260-is-this-safe/#findComment-587523
Share on other sites

Oh, well, that's a given.

 

I always create my own escape function anyways... typing out mysql_real_escape_string is painful!

 

<?php

function dbSanitize ( $input, $quote = FALSE ) {

# Parse array
if ( is_array($input) )
	foreach ($input as $key => $var)
		$input[$key] =	dbSanitize( $var, $quote );

# Parse string
else {
	# Check if already escaped
	if (get_magic_quotes_gpc())
		# Remove useless escapes
		$input = stripslashes($input);

	# Sanitize and quote if necessary
	$input =
		( $quote ? '\'' : '' ) .
		mysql_real_escape_string($input) .
		( $quote ? '\'' : '' );
}

# Return sanitized string
return $input;

}

?>

Link to comment
https://forums.phpfreaks.com/topic/114260-is-this-safe/#findComment-587780
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.