I have a problem with the charset config somewhere – and need some help.
I am using a jQuery jeditable to update values to a database through php. When I post øæå through this script, the database is populated with æøå instead. I’ve tried to utf8_encode aswell, but with no luck. A regular post with øæå works fine
$(document).ready(function() {
$('.update_pipu_comment').editable('http://lin01.test.no/save.php?update=pipu_comment', {
event : 'dblclick',
submit : 'ok',
indicator : '<img src="image/indicator.gif">',
tooltip : 'doubleclick to edit'
});
});
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
//save.php
require('config.php');
$postvalue = $_POST[value];
$id = $_POST[id];
$update = $_GET[update];
if($update == 'pipu_comment') {
$res = mysql_query("UPDATE pinpuk SET comment = '$postvalue' WHERE id = '$id'");
}
echo $postvalue;
You can set charset first to UTF-8:
Also your code is not SQL safe:
As a side note, you should try to move to MySQLi or PDO. Here is a nice tutorial to get you started in using PDO.