cloudll Posted October 9, 2011 Share Posted October 9, 2011 I have never looked into sanitizing before, Is using htmlentities() good enough to protect against sql injection ? Thanks. Quote Link to comment Share on other sites More sharing options...
awjudd Posted October 9, 2011 Share Posted October 9, 2011 You shouldn't be using htmlentities to prevent SQL injection. There are other functions to do that for you (i.e. mysql_real_escape_string) or better yet, use database parameters. ~juddster Quote Link to comment Share on other sites More sharing options...
cloudll Posted October 9, 2011 Author Share Posted October 9, 2011 Ah ok, the only reason I was thinking about htmlentities is because wouldnt it allow me to see what someone was atempting to do? if they did try any injection? would i use it like this: $statement->execute(array mysql_real_escape_string($sector), mysql_real_escape_string ($battle,$id)); or am i supposed to use it like this? $name = mysql_real_escape_string($_POST['admin_name']); Quote Link to comment Share on other sites More sharing options...
awjudd Posted October 9, 2011 Share Posted October 9, 2011 If you are using database parameters for your query there is no need to escape them. Or if you aren't you would do something like what you have at the bottom. ~juddster Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.