Quantcast
Channel: Topic Tag: MySQL | WordPress.org
Viewing all articles
Browse latest Browse all 5530

nonridomai on "Mysql charset problem è ù ì ò à"

$
0
0

Hi everybody,
I've been looking for the answer of my problem all over the place but I couldn't fine one that works.
I've read this and several other posts.

Here is my problem.
I've created a DB in PHPMyAdmin. 366 lines, one for each possible day of the year.
Then on my sidebar I wrote these lines in PHP to retrieve the daily quote:

date_default_timezone_set("Europe/Rome");

$mydate=getdate(date("U"));
$month=$mydate[month];
$day=$mydate[mday];

$con=mysqli_connect("IP address","user","password","DBname");
// Controllo connessione
if (mysqli_connect_errno()) {
echo "Impossibile connettersi al DB" . mysqli_connect_error();
}
else {
mysqli_query("SET NAMES 'utf8'", $con);
$result = mysqli_query($con,"SELECT * FROM sd_ita WHERE month='$month' AND day='$day' ");

while($row = mysqli_fetch_array($result)) {
echo "" . $row['day'] . " " . $row['mese'] . '

<p charset="latin1">' . $row['title'] . "

" . $row['text'] . "

" . $row['source'];
echo "";

mysqli_free_result($result);
}

mysqli_close($con);
}

?>

Sorry I just don't want to specify the IP location, user and password of my DB. The code works well by the way.

The problem is that characters like ò-à-è-ù-ì are displayed like "?" or something like this.

wp_config charset is UTF8_general_ci
On the page header I specified as charset UTF8
Each text field and table of Both DB, wordpress and the one I've created, have the charset UTF8_general_ci set.
I tried embedding this code in php mysqli_query("SET NAMES 'utf8'", $con); but it didn't work. Any suggestion?
Thanks


Viewing all articles
Browse latest Browse all 5530

Trending Articles