djrichwz Posted October 30, 2008 Share Posted October 30, 2008 I have a problem where If I insert text into the mysql with single quotes such as 'treble' the quotes do not display on the retrieved result they display as �treble�. How do I solve this with php I cannot move on with this project until this is solved please can anybody help. :-\ Link to comment https://forums.phpfreaks.com/topic/130722-text-from-database-doesnt-display-single-qoutes/ Share on other sites More sharing options...
waynew Posted October 30, 2008 Share Posted October 30, 2008 Have you specified a charset for your page? Are you using htmlentities to ouput this? Link to comment https://forums.phpfreaks.com/topic/130722-text-from-database-doesnt-display-single-qoutes/#findComment-678388 Share on other sites More sharing options...
djrichwz Posted October 30, 2008 Author Share Posted October 30, 2008 no i havent specified a characterset for the page (how do you do that) and yes it is using htmlentities Code: include('dbinfo.php'); // connect to DB. $conn = mysql_connect( $dbhost, $dbuser, $dbpass ); mysql_select_db($dbname); $result = mysql_query("SELECT * FROM history order by ID DESC"); $row = mysql_fetch_array($result) or die(mysql_error()); $history=$row['history']; $quote = nl2br(htmlentities($history)); echo $quote."<BR>\n"; I used htmlentities to solve the hyphen problem (text-text) Link to comment https://forums.phpfreaks.com/topic/130722-text-from-database-doesnt-display-single-qoutes/#findComment-678393 Share on other sites More sharing options...
waynew Posted October 31, 2008 Share Posted October 31, 2008 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> echo htmlentities($string,ENT-QUOTES,"utf-8"); Link to comment https://forums.phpfreaks.com/topic/130722-text-from-database-doesnt-display-single-qoutes/#findComment-679262 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.