I got this table with a column name Catégorie which I can’t rename (long story) and that é is bothering me big time.
I can’t seem to query that column.
I got the following code
$query_brands = "SELECT distinct catégorie as merk FROM GSProduct";
$resultBrands = $phpbb->query($query_brands);
$brandArr = array();
foreach($resultBrands as $brand){
$brandArr[$brand->merk] = $brand->merk;
}
In mysql the query works fine, but in php I get an exception:
PDOException: in meisjesschoenen_filter_form() (line 198 of /home/mediaspe/domains/mediaspex.be/public_html/juniorsteps/sites/all/modules/meisjesschoenen/meisjesschoenen.module)
I tried putting it between ' ' but then I just get 1 empty result instead of the 7 results I should get
Help is appreciated a lot!!
UPDATE:
I found the following lines of code in settings.php and I added the collation ad followed:
array (
'juniorsteps_gem' =>
array (
'database' => '*****',
'username' => '*****',
'password' => '*****?',
'host' => 'localhost',
'port' => '',
'driver' => 'mysql',
'prefix' => '',
'collation' => 'utf8_general_ci',
),
Also I found in mysql that the collation of my database/table also is utf8_general_ci so that should be ok.
UPDATE2 (could not self answer yet)
The problem was my file.
I’ve used notepad++ to convert my file from ANSI to UTF 8 and now it works.
Thx all for the push in the right direction!!
Ensure that the file you’re writing the SQL statement is correctly encoded, e.g. UTF-8. That’s a setting in the editor you’re using.
Otherwise you are sending the wrong characters to the database, because you get a PDO Exception an invalid one.