messer Posted May 7, 2009 Share Posted May 7, 2009 I've got this error : Warning: htmlentities() expects parameter 1 to be string, array given in /xxx/yyy/domains/wwwcom.com/public_html/some/page.php on line 11 And this is my function: function addentities($data){ if(trim($data) != ''){ $data = htmlentities($data, ENT_QUOTES); <------- line 11---- return str_replace('\\', '\', $data); } else return $data; } Anyone some ideeas??? Quote Link to comment https://forums.phpfreaks.com/topic/157272-htmlentities-problems/ Share on other sites More sharing options...
premiso Posted May 7, 2009 Share Posted May 7, 2009 $data is an array....You can do this, but you need to figure out why it is an array: function addentities($data){ if (is_array($data)) $data = implode(" ", $data); if(trim($data) != ''){ $data = htmlentities($data, ENT_QUOTES); return str_replace('\\', '\', $data); } else return $data; } That will basically convert the array to a string, but you are expecting a string, the answer is not here. It is where you are calling that function, not where it is defined. Quote Link to comment https://forums.phpfreaks.com/topic/157272-htmlentities-problems/#findComment-828853 Share on other sites More sharing options...
messer Posted May 7, 2009 Author Share Posted May 7, 2009 Thx, i replaced it and it works, but i'm asking myself, before my function worked fine,no problem... i don't get why today it hapend so??? ??? Quote Link to comment https://forums.phpfreaks.com/topic/157272-htmlentities-problems/#findComment-828865 Share on other sites More sharing options...
Ken2k7 Posted May 7, 2009 Share Posted May 7, 2009 Probably before your $data wasn't of type array. Quote Link to comment https://forums.phpfreaks.com/topic/157272-htmlentities-problems/#findComment-828875 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.