Jump to content

problem with accents


Recommended Posts

i installed a shoutbox on my website... now i am trying to make an "archive" page for the shoutbox

 

my code is really simple:

<?php

include("db.php");

mysql_query("SET CHARACTER SET utf8");

mysql_query("SET NAMES utf8");

 

$query = "SELECT * FROM tbl_qshout ORDER BY chat_id DESC LIMIT 1,100";

 

$res = mysql_query($query) or die(mysql_error()); 

while($row = mysql_fetch_array($res)) {

 

$user=$row["user"];

$message=$row["message"];

$date_post=$row["date_post"];

$url=$row["url"];

echo "<b><a href=\"$url$user\">$user:</a></b> $message ($date_post)<br><br>";

}

?>

 

the problem is that all accents will be messed up (characters like é è â à ç  etc...) in $row["message"]

 

i tryed a lot of things : utf8_decode, utf8_encode, htmlentities, html_entity_decode, etc.... i even tryed to remove the accents with str_replace or preg_replace...

 

usually i can solve my accents problem with one of those function or simply with the utf-8 mysql query

 

but this time i can't find a way to solve my problem  :wtf:

 

someone please help me !!!

Link to comment
Share on other sites

mm sorry not sure then but wordpad does not work with php and utf 8 for some reason upload the file to your server and then open the file in your cpanel and see if the accents are in your code if they are then check to see if the problem is in your database you may have to change the fields to longblob to get it to work

Link to comment
Share on other sites

there is no accents in my script, accents come from the result of the query to database...

 

and i already saved the file to utf-8 with the editor you told me to use

 

it isn't a problem with the table of the database since the shoutbox script can correctly display the content of the message WITH the accents.... i don't understand why it doesn't work with my own script

Link to comment
Share on other sites

yes but can your database save the accents in the field correctly if it is set to varchar maybe it will save the accents as $#-! (gibberish) try changing it to blob or longblob from varchar also is the sql insert on the same page as the utf8 page if not the sql insert page needs to be utf8 too

Link to comment
Share on other sites

just tryed to change it to longblob, still the same errors

 

anyway like i said it isnt a problem with the database structure since the shoutbox script using the same messages in the same table of the same database is displaying the accents without any problem

 

in fact, the messages in the database are already filtered with htmlentities and looks like this:

 

ouè man

 

 

Link to comment
Share on other sites

it is a problem recalling it i'm 100% sure

 

my database is set to utf8 and it is saving correctly, when i check in phpmyadmin the accents are correct

 

and like i said, i am calling the data from the database/table of my shoutbox.... i just want to display the messages sent in the shoutbox on a different page... The shoutbox is already displaying the text from the database with the correct accents.... So if it was a problem with saving the data there would be display errors on the shoutbox too

Link to comment
Share on other sites

 

This page has invalid HTML structure and no character encoding information either in meta tag or in HTTP response.

Here are the HTTP headers for this page:

Date: Sat, 05 Jun 2010 12:35:04 GMT
Server: Apache
X-Powered-By: PHP/5.2.6-1+lenny8
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 4022
Keep-Alive: timeout=5, max=150
Connection: Keep-Alive
Content-Type: text/html

200 OK

 

On the other hand, when your shoutbox retrieves messages from server it gets these headers:

 

Date	Sat, 05 Jun 2010 12:37:55 GMT
Server	Apache
X-Powered-By	PHP/5.2.6-1+lenny8
Expires	Mon, 26 Jul 1997 05:00:00 GMT
Last-Modified	Sat, 05 Jun 2010 12:37:55GMT
Cache-Control	no-cache, must-revalidate
Pragma	no-cache
Vary	Accept-Encoding
Content-Encoding	gzip
Content-Length	2714
Keep-Alive	timeout=5, max=148
Connection	Keep-Alive
Content-Type	text/plain; charset=utf-8

See the very last here?

Link to comment
Share on other sites

looking through the source of this page:

hey je prend l pack de bière

 

Something is replacing these characters with html entities. There's no way a browser can display it correctly.

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.