Reputation: 1122
I keep getting the silly invalid byte sequence for encoding "UTF8": 0x96
error or whatever it is. Now I've identified it as a problem with my server space.
The thing is I migrated from a very similar database which was also UTF-8. I test out my PHP scripts on the first database and they work but on the one I require they do not. It must be a problem with encoding but I'm not sure what.
My PHP queries are failing on the new database and producing that error.
PHP:
$name = $_POST["name"];
$type = $_POST["type"];
$contact = $_POST["contact"];
$address = $_POST["address"];
$postcode = $_POST["postcode"];
$phone = $_POST["phone"];
$description = $_POST["description"];
$location = $_POST["location"];
$conn = pg_connect(/*DATABASE CONNECTION DETAILS*/);
$res = pg_query("INSERT INTO address (organisation_type, contact_name, address, postcode, phone_number, description, location_to_town, organisation_name) VALUES ('$type', '$contact', '$address', '$postcode', '$phone', '$description', '$location', '$name')");
pg_close($conn);
I mean that is a simple PHP write to database function and the only oddity is that of one UTF-8 database working and the other not. Is there any way I can compare the server/change the configurations of my PostGreSQL server at the command line?
Thanks any information would be much appreciated. Tearing my hair out over this!
Upvotes: 0
Views: 382
Reputation: 2856
The error message names 0x96, which does not look like UTF-8 but rather a dash in some 8 bit charset. Make sure that you are posting UTF-8, by setting the correct meta header in your HTML:
<meta http-equiv="content-type" content="text/html; charset=utf-8">
Or sending the charset with a content type HTTP header on the PHP side:
header('Content-Type: text/html; charset=utf-8');
Upvotes: 2