Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating google chart from mysql column with accent

I'm generating google charts from different months in a year. Every month seems to work fine except for months(février) with accent. It has an error message saying Table has no column. In the mysql table I have a column like this (1-févr), (2-févr) ... Is the accent the cause of the error? If so, how could I fix it? Thanks!

EDIT: I realised the problem is with JSON_encode, and all I needed to do is to use the utf8_encode function to my data before I convert them to JSON.

like image 440
lswei Avatar asked Nov 18 '25 13:11

lswei


1 Answers

When selecting the column form the database use backticks surrounding the column name, so the query before would look like so:

SELECT 1-févr, 2-févr FROM table

This would need to be changed to:

SELECT `1-févr`, `2-févr` FROM table

Please be careful, these are backticks and not quotes ie it is ` and not ' or ".

This ensures the string is evaluated as a whole and not broken due to characters such as hyphens etc.

like image 67
The Humble Rat Avatar answered Nov 21 '25 04:11

The Humble Rat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!