Backup and Restore a web site in CPANEL

August 16, 2009 Rui Miguel Feio

It’s a good practice to make backups prior to submit any changes to your site. Time and again people skip the backup to find themselves with problems and not having an easy and quick way to undo their changes. This may not seem a big problem, but if the changes […]

How to select the First row from a MySQL table

July 6, 2009 Rui Miguel Feio

You can use the following command to get the first row from a MySQL table: SELECT * FROM table LIMIT 1 Explanation: table – table name   By limiting the returns to 1 (LIMIT 1) we get the first row from the table. Example: SELECT * FROM tusers LIMIT 1

How to select the Last row from a MySQL table

July 6, 2009 Rui Miguel Feio

You can use the following command to get the last row from a MySQL table: SELECT * FROM table ORDER BY field DESC LIMIT 1 Explanation: table – table name field – table field This command orders the table by DESCENDING order and limits the number of rows returned to […]

Select random rows from a MySQL table

July 6, 2009 Rui Miguel Feio

If you ever come across the need of randomly select rows from a MySQL table: SELECT * FROM table WHERE field1 = value ORDER BY RAND() LIMIT x Explanation: table – table name field1 – table field value – value you want field1 to be x – number of rows […]

How to identify a MySQL query problem

July 1, 2009 Rui Miguel Feio

Sometimes you happen to have a problem with one of your MySQL queries and you simply can’t seem to understand why. Well, one thing that helps is to use the mysql_error() function. This function returns the message of the MySQL error you’re getting. Example: $action = “INSERT INTO table (name, […]

1 2