Perfidus Posted March 24, 2009 Share Posted March 24, 2009 Hi there again, before introducing my data in mysql I'm using mysql_real_escape_string(). Afterwords, when I want my data back, I'm applying to every result this two functions: utf8_encode(stripslashes($row['result1'])) Is there a way to apply this double function somewhere before so I don't need to write it down again and again for every result? Somewhere in the query function... function getData($ref) { $sql="SELECT * FROM thetable WHERE ref= '$ref"; $rs = mysql_query($sql) or die(mysql_error() . "<br>$sql"); $row = mysql_fetch_array($rs); return $row; } Link to comment https://forums.phpfreaks.com/topic/150893-cleaning-mysql-results/ Share on other sites More sharing options...
Perfidus Posted March 24, 2009 Author Share Posted March 24, 2009 And again I'm answering myself... Please, if someone has a suggestion, tell me, I have tried this and it works like a charm. function getData($ref) { $sql="SELECT * FROM thetable WHERE ref= '$ref"; $rs = mysql_query($sql) or die(mysql_error() . "<br>$sql"); $row = mysql_fetch_array($rs); foreach ($row as &$value) { $value = utf8_encode(stripslashes($value)); } unset($value); // return $row; } Link to comment https://forums.phpfreaks.com/topic/150893-cleaning-mysql-results/#findComment-792705 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.