Jump to content

mysql statement error!


unistake

Recommended Posts

Hi all,

 

In my mysql database I have a small note about a product e.g. "this retails at £29.99".

 

The problem is that when I come to echo this $note in php it does not display the £ character but a black diamond shape with a question mark in it!

The mysql field is a VARCHAR length 100. How can this be changed so it displays the £ sign?

 

Thanks

 

Link to comment
Share on other sites

I am still having trouble to get this to work.

 

The field in mysql is accessed with php and the variable being $details. It is a VARCHAR (100 length) and can include text along with a price with the sterling symbol.

 

When i come to echo the $details it comes up with a symbol.

 

I have tried

$details = htmlspecialchars($details);

and then echoing $details in php, but i am not sure that is how to use the htmlspecialchars in this particular case???

 

Can anyone show me how to use it ?

 

Thanks

Tim

Link to comment
Share on other sites

 
<head>
<script>
function DoNav(theUrl)
  {
  document.location.href = theUrl;
  window.open(theUrl, 'newwindow');
  }
  </script>
</head>
<body>
<?
$cxn = mysqli_connect($host, $user, $password, $database)
or die ("cant connect to the database");

$query = "SELECT * FROM database";

$result = mysqli_query($cxn,$query)
or die ("Can't execute query!");

        echo  "<table width='900' cellspacing='0' cellpadding='10'>";

while ($row = mysqli_fetch_assoc($result))
{
extract($row);
$details = htmlspecialchars($details);
echo "<tr onclick=\"DoNav('$link');\">
          <td><img src='images/bmks/$name.jpg' width='100' height='30' /></td>
          <td class='display'>$name</td>
          <td class='display'>£$price</td>
          <td class='display'>$minodds</td>
          <td class='display'>$sr</td>
          <td class='display'>$pf</td>
[size=4]          <td class='display'>$details</td>[/size]
        </tr>";
}
echo "</table>";
?>
</body>

 

Thanks :)

Link to comment
Share on other sites

Hi

 

To use htmlspecialchars you could just do:-

 

<td class='display'>".htmlspecialchars($details)."</td>

 

However I doubt that this is the problem (do a view source on the generated page to see what has been output, rather than what the browser has translated it to).

 

I would suspect it is something to do with character sets.

 

All the best

 

Keith

Link to comment
Share on other sites

the issue with using htmlspecialchars, and mysql database data. Please dont try to be smart!

 

If you dont know the answer then leave it!

Those are separate issues -- kickstart is trying to figure out which side is the problem.

 

I was simply trying to determine if the data is coming back properly, irrespective of htmlspecialchars(), with has nothing to do with mysql.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.