Skip to main content

Posts

Showing posts from May, 2020

Connecting to MySQL 8 from Old PHP version using mysqli

If you have upgraded your MySQL to MySQL 8 version and still using older version of PHP you might encounter a few problems in the connection using mysqli connector library. 1. The first problem we are going to solve is: php mysql 8: "Server sent charset (255) unknown to the client. Please, report to the developers" The problem is that MySQL have changed the default character set from utf8 to utf8mb4 and it is not supported by mysqli connector (nor PDO as I have checked) in older versions of php. "The default collation for utf8mb4 differs between MySQL 5.7 and 8.0 ( utf8mb4_general_ci for 5.7, utf8mb4_0900_ai_ci for 8.0). When the 8.0 client requests a character set of utf8mb4 , what it sends to the server is the default 8.0 utf8mb4 collation; that is, the utf8mb4_0900_ai_ci." https://dev.mysql.com/doc/refman/8.0/en/charset-connection.html The way to solve it easily (there are other ways, such as upgrading php or connectors and more ...) is to force MySQL 8.0 to ...

Simple system to track errors in code and find them easily

Hi, Here is a trick I developed during my years as a developer / programmer and team code leader. This system not just helps you to find the location of the error or warning in the code, but also who wrote it (without the need to open Git Blame or SVN log) and when was it coded in written. They say that grep (find in all files) is the best friend of the programmer. Hence if you see an error in text or log file, let's say "Error: can't find configuration file". So you copy the text and "grep" it. It might be you would find this string in a few places scattered around the code. So, we have started to give some Error Codes to the error. For example "Error: can't find configuration file (1029)". This will make it much easier and this unique error code is easy to search inside all the code files. So how do you keep all the Error Codes unique ? Maybe a new programmer will add the same code number. Do you keep a file with all Error Codes ...