PHP MySql query for random record from database table

September 5, 2014

The simplest way of selecting random rows from the MySQL database is to use “ORDER BY RAND()” clause in the query. Example:

Ubuntu phpmyadmin connect to mysql error: #2002 cannot log in to the mysql server

August 22, 2014

If phpmyadmin cannot connect to mysql error: #2002 cannot log in to the mysql server Run: sudo nano /etc/mysql/my.cnf Update bind-address = 192.168.0.2 To bind-address = localhost This fixed the problem. Enjoy. ref: here

PHP Prepare IN statement from array

April 14, 2014

Some of us may not know that when preparing mysql IN statement, the string inside the IN() need to be single quoted and separated by comma. Example: Unless it is a number. Otherwise double quote or no quoting the string will give you error. Example: WHERE categories IN (“red”, “blue”, “green”) To prepare IN statement […]

Ubuntu check PHP and mysql version

April 7, 2014

From command line: php -v mysql -V or php -i | grep -i ‘^libxml’

MySQL modify field value allow NULL

December 19, 2013

Columns are nullable by default. As long as the column is not declared UNIQUE or NOT NULL . However, things may change during development or to prevent insert error. Thus, run this comman, example: