I am using PHP to populate a database of company records. I have a field for company name and the currency type that they use.
But when I use PHP the record never gets inserted if the currency is an Enlglish pound sign (£). A dollar sign ($) or any other normal character is no problem. The record with a pound sign inserts just fine when I run the sql statement and enter it directly into MySQL Query Browser. But it just doesn't work when I run the exact same INSERT statement in PHP.
$sql = "INSERT INTO company_test (name, currency) VALUES ('ABC Widgets', '£')";
$rs = mysql_query($sql, $conn);
//Does not insert a record
$sql = "INSERT INTO company_test (name, currency) VALUES ('ABC Widgets', '$')";
$rs = mysql_query($sql, $conn);
//A record inserts just fine
//My MySQL version is 5.5.11. PHP is version 5.3.6.
//The MySQL table looks like this:
TABLE company_test
FIELD | id | INTEGER(10) | not null | auto increment
FIELD | name | VARCHAR(45) | not null
FIELD | currency | VARCHAR(3)
In MySQL Query Browser the "Table Options" tab shows that for this company_test table my charset is utf8.
Thanks.