Jump to content

Text from database doesnt display single qoutes


djrichwz

Recommended Posts

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.  :-\

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)

<!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");

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.