How-to articles, tricks, and solutions about MYSQL
Best way to check if mysql_query returned any results?
To check if a MySQL query returned any results, you can use the mysqli_num_rows function.
Calculate age based on date of birth
Here is some sample PHP code that calculates a person's age based on their date of birth:
Checking for an empty result (PHP, PDO, and MySQL)
In PHP, you can use the PDO (PHP Data Objects) extension to interact with a MySQL database.
Codeigniter's `where` and `or_where`
In CodeIgniter, the where method on the database class is used to add a WHERE clause to your query.
error in your SQL syntax; check the manual that corresponds to your MySQL server
This error message is indicating that there is a problem with the SQL syntax used in the query.
Error when preparing a multiple insert query
There are a few things that could cause an error when preparing a multiple insert query in PHP.
Example of how to use bind_result vs get_result
The mysqli_stmt::bind_result() method binds variables to a prepared statement for result storage.
How can I enable the MySQLi extension in PHP 7?
To enable the MySQLi extension in PHP 7, you need to follow these steps.
How can I prevent SQL injection in PHP?
There are several ways to prevent SQL injection attacks in PHP.
How do I connect to a MySQL Database in Python?
To connect to a MySQL database in Python, you can use the mysql-connector-python library.