sometimes mysql doesn't let you insert data into your database unless its cleaned.
an good way to do this is with the function:
mysql_real_escape_string()
example:
mysql_real_escape_string($_POST['somedata'])
but its better to use this instead:
trim(stripslashes($_POST['somedata']))
WARNING: but if you have a website, you MUST use
mysql_real_escape_string() for security
Comments and replies About another way to use mysql_real_escape_string instead trim(stripslashes(
Wayne:
no. stripslashes can be fooled. mysql_real_escape_string is the only action to take against sql injection
shawn:
this is wrong... the function would be addslashes. e.g., trim(addslashes($_post['somedata'
This:
this is horribly wrong, do not use this advice.
horrified:
stripslashes, to sanatise pre-db entry?
is this site a hacking site wanting people to have hghly insecure scripts?
anyone reading this, forget add and strip slashes. use mysql_real_escape_string()
i you get slashes from php from some other place, then use stripslashes by all means
i20:
first it's not strip but addslashes to escape illegal characters and second nothing can replace mysql_real_escape_string() for stop injection because this function has been created exactly to protect your mysql_query!! "trim(stripslashes($_post['someda is a joke!