How-to articles, tricks, and solutions about MYSQL

Save PHP array to MySQL?

To save a PHP array to a MySQL database, you can use the serialize() function to convert the array into a string, and then use an INSERT or UPDATE statement to save the string into a TEXT or LONGTEXT field in the database.

Select mySQL based only on month and year

To select data from a MySQL database based on the month and year, you can use the MONTH and YEAR functions in your SELECT statement.

Select records from today, this week, this month php mysql

To select records from today, you can use the following code:

selecting unique values from a column

To select unique values from a column in PHP, you can use the array_unique function.

Solving a "communications link failure" with JDBC and MySQL

A "communications link failure" error when using JDBC and MySQL can be caused by several factors. Here are a few potential solutions:

SQLSTATE[42S22]: Column not found: 1054 Unknown column

It looks like you are encountering an error with the message "SQLSTATE[42S22]: Column not found: 1054 Unknown column".

SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost'

This error message typically indicates that the MySQL server is unable to authenticate the user 'root'@'localhost' with the provided password.

The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead

It is true that the MySQL extension is deprecated, and it is recommended to use either MySQLi or PDO instead.

Using env variable in Spring Boot's application.properties

You can use environment variables in your application.properties file by using the spring.profiles.active property.

UTF8 Encoding problem - With good examples

UTF-8 is a character encoding that represents each character in a text document as a unique numerical code.

Warning: mysqli_connect(): (HY000/2002): No such file or directory

This error message is indicating that there is a problem connecting to the MySQL server.

Why shouldn't I use mysql_* functions in PHP?

The mysql_* functions in PHP are deprecated, meaning that they are no longer recommended for use and will likely be removed in a future version of PHP.

1 2 3 4