Web & Software Developer

Code Snippets and Tutorials

PHP – Count Rows in MySQL Database Table

This is a quick PHP function to count rows in a MySQL database table. It takes 2 parameters, which are: $link This is the MySQL connection object which is made, for example, by using mysqli_connect(). $table The name of the table that you want to count rows for. The function will a return an integer, … Read more →

Error Codes For system(“unzip archive.zip”) in PHP

If you’re using system("unzip archive.zip") to unzip an archive file in PHP, and you want to catch errors, you’ll notice that it only returns a number for the error code. Here are the error codes (exit status codes) and meanings for the unzip command. This PHP array matches the unzip error code with its meaning. … Read more →

Run Code Only Once in WordPress

You may have a function or some code that you only want to run one time on your WordPress site. You may notice that functions hooked on to admin_init can be fired twice. Here is quick way to run your code only once. This will guarantee that it runs one, and only one, time. Mandatory … Read more →