chocopi Posted June 12, 2007 Share Posted June 12, 2007 Am I using this wrongly ? My data is submitted into the database using htmlspecialchars(), but when I retrieve the data and then try and decode it, I get this error: Call to undefined function: htmlspecialchars_decode() on line 6 Line 6: $text = htmlspecialchars_decode($text); Thanks, ~ Chocopi Quote Link to comment https://forums.phpfreaks.com/topic/55312-solved-htmlspecialchars_decode/ Share on other sites More sharing options...
The Little Guy Posted June 12, 2007 Share Posted June 12, 2007 No... What version on PHP are you using? You need PHP 5+ other wise use this: html_entity_decode($text); Quote Link to comment https://forums.phpfreaks.com/topic/55312-solved-htmlspecialchars_decode/#findComment-273410 Share on other sites More sharing options...
chocopi Posted June 12, 2007 Author Share Posted June 12, 2007 Yea im not using 5< so it didnt work Just out of intrest should i bother using addslashed() is im using htmlentities() ? THANKS little_guy, ~ Chocopi Quote Link to comment https://forums.phpfreaks.com/topic/55312-solved-htmlspecialchars_decode/#findComment-273415 Share on other sites More sharing options...
kenrbnsn Posted June 12, 2007 Share Posted June 12, 2007 Why are you using htmlspecialchars() when storing your data? You probably want to use the function mysql_real_escape_string() instead. Ken Quote Link to comment https://forums.phpfreaks.com/topic/55312-solved-htmlspecialchars_decode/#findComment-273416 Share on other sites More sharing options...
chocopi Posted June 12, 2007 Author Share Posted June 12, 2007 so i can stop " ' & < > being entered into my database Quote Link to comment https://forums.phpfreaks.com/topic/55312-solved-htmlspecialchars_decode/#findComment-273418 Share on other sites More sharing options...
kenrbnsn Posted June 12, 2007 Share Posted June 12, 2007 Use the function mysql_real_escape_string() for that. Escaping those characters (and a few others) is it's function. Ken Quote Link to comment https://forums.phpfreaks.com/topic/55312-solved-htmlspecialchars_decode/#findComment-273419 Share on other sites More sharing options...
chocopi Posted June 12, 2007 Author Share Posted June 12, 2007 okie dokie, i will change it, Cheers Ken Quote Link to comment https://forums.phpfreaks.com/topic/55312-solved-htmlspecialchars_decode/#findComment-273427 Share on other sites More sharing options...
chocopi Posted June 12, 2007 Author Share Posted June 12, 2007 so doing something like this is better $original = mysql_real_escape_string($original); than $original = htmlentities($original); ~ Chocopi Quote Link to comment https://forums.phpfreaks.com/topic/55312-solved-htmlspecialchars_decode/#findComment-273430 Share on other sites More sharing options...
The Little Guy Posted June 12, 2007 Share Posted June 12, 2007 for SQL, Yes Quote Link to comment https://forums.phpfreaks.com/topic/55312-solved-htmlspecialchars_decode/#findComment-273437 Share on other sites More sharing options...
chocopi Posted June 12, 2007 Author Share Posted June 12, 2007 kool Cheers everyone ;D Quote Link to comment https://forums.phpfreaks.com/topic/55312-solved-htmlspecialchars_decode/#findComment-273439 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.