Garethp Posted August 20, 2009 Share Posted August 20, 2009 Ok, so I've been using this for a small while to make typing in variables ALOT quicker, but is it secure? If not, can I make it more secure? foreach($Array as $k=>$v) { $k = mysql_escape_string($k); $v = mysql_escape_string($v); $$k = $v; } Link to comment https://forums.phpfreaks.com/topic/171118-is-this-secure/ Share on other sites More sharing options...
markwillis82 Posted August 20, 2009 Share Posted August 20, 2009 I would use mysql_real_escape_string - and also instead of creating many new variables (potentially hundreds), you could put them into a "safe" array foreach($Array as $k=>$v) { $k = mysql_real_escape_string($k); $v = mysql_real_escape_string($v); $safe_input[$k] = $v; } Link to comment https://forums.phpfreaks.com/topic/171118-is-this-secure/#findComment-902405 Share on other sites More sharing options...
Garethp Posted August 20, 2009 Author Share Posted August 20, 2009 That's a good idea, thanks. What's the difference between real and not real? Link to comment https://forums.phpfreaks.com/topic/171118-is-this-secure/#findComment-902408 Share on other sites More sharing options...
markwillis82 Posted August 20, 2009 Share Posted August 20, 2009 mysql_escape_string is deprecated in php 5.3 mysql_real_escape_string is the better function Link to comment https://forums.phpfreaks.com/topic/171118-is-this-secure/#findComment-902412 Share on other sites More sharing options...
Garethp Posted August 20, 2009 Author Share Posted August 20, 2009 Can I use it without connecting to a database? Link to comment https://forums.phpfreaks.com/topic/171118-is-this-secure/#findComment-902414 Share on other sites More sharing options...
markwillis82 Posted August 20, 2009 Share Posted August 20, 2009 You would need to make a database connection first - You can try without but I might throw a warning error. Alternativly you could use str_replace and arrays of "find" and "replace" Link to comment https://forums.phpfreaks.com/topic/171118-is-this-secure/#findComment-902425 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.