WordPress Blank Dashboard

I recently moved one of my blogs to Linode, a VPS hosting company. I noticed right away, when I logged in as admin, that the WordPress Dashboard, displayed a blank page. That’s not good. So, I started removing plugins by renaming the plugin directories until I found the offending plugin. Sure enough, it was a custom plugin I wrote myself.

Nothing has changed. The plugin hasn’t been touch. WordPress is the same latest version. The only thing that changed was the host server. So, I started looking into my PHP installation. What could possibly be missing? When I looked into my plugin code, I noticed some references to curl. I realized my server was missing a php5-curl module on the new host server.

A simple command to install php5-curl on the new server does the trick.

sudo apt-get install php5-curl

In this particular case, a missing module in PHP, caused the plugin to die unexpectedly, resulting in a blank Dashboard page within WordPress. Removing offending plugins temporarily fixes the issue, but it doesn’t get to the root of the problem. In my case, I was able to narrow it down to the missing PHP curl module that my plugin desperately needs.

In any case, everything is back to normal as expected, except for the blog, which is serving pages exceptionally fast, since I’m now running at Linode.

Install CodeIgniter The Secure Way

CodeIgniter is a PHP framework for rapid application development. It’s exceptionally fast and it comes in a small footprint. Installing CodeIgniter is fairly straightforward. You just upload the CodeIgniter files and folders to the directory of your choice.

But, for a much more secure installation, you should probably move the application and system folders above your webroot folder, so that nobody has direct access to it. In addition to moving them, you also need to set the full server paths in the main index.php. You will need to edit index.php found in the main CodeIgniter folder.

Change the following entries to:

$system_path - '/full-server-path/system';
$application_folder = '/full-server-path/application';

Save. That should do it.

Get Your OwnCloud

There are several free cloud services available out there. Dropbox, Google Drive, Ubuntu One, JustCloud, ZipCloud, to name just  a few. They’re all great. They all have one thing in common, they store and share files and documents on the cloud.

If there’s one thing that bothers people about cloud services, it’s privacy. People worry about placing sensitive data on the cloud. How about running your own cloud? Well, get your own cloud with OwnCloud. OwnCloud is an open-source cloud software solution that you can install yourself.

You can install it on your own desktop, your server at home, your VPS server on the Internet, or anywhere there is a PC or computer. You decide where you want it. The best thing about ownCloud, no one has access to your sensitive data. Just you.

I’ve been running ownCloud for about a month now. It’s great. I am able to upload and share any files that I want, from pictures, videos and documents.  I can access these files from any computer, from any location around the world. There is no need for me to carry a USB stick anymore. All I need to do, is access my browser and access my files online.

In addition, OwnCloud allows me to play music and movies online. It organizes my pictures into galleries. It has a calendar, contacts, and a host of other applications that can be installed with just one click of a button. So, get your own cloud with OwnCloud.

Linode Kicks Ass

Get a web server running within minutes. Choose a Linux distro, resources, and node location. That’s essentially Linode in a nutshell. I signed up with Linode about two weeks ago. I’ve been playing around with it since then. I can happily say that I’m very impressed with Linode. It has exceeded my expectations.

If you want total control of your web server, Linode VPS is really the way to go. You will be asked to choose server size when you sign up. They come in many configurations. I chose Linode 512. You also need to choose a data center location. There are six data centers worldwide. I choose the one in Fremont since I live in California.

So far, I’m loving the guaranteed server resources. My websites are running faster . I chose Ubuntu 12.04 LTS 32 bit because it’s a Linux distro I am very familiar with. Apparently, 57% Linode users have chosen Ubuntu as well. I already transferred a couple of domains over to Linode. The websites are screaming.

I plan to migrate more websites later. If you are curious about how Linode works, here is a short list of features to get you started:

  • Full ssh and root access
  • Guaranteed Resources
  • 4 processor Xen instances
  • Out of band console shell
  • Dedicated IP address, premium bw
  • Six datacenters in the US, Europe, and Asia-Pacific
  • HA and Clustering Support
  • Bandwidth pooling
  • Managed DNS with API


PHPVirtualBox is a web-based program that allows you to control a remote Virtualbox GUI. PHPVirtualBox is ideal for systems that don’t have remote GUI access. Access is done via a browser. Remote virtual machines can be started and stopped, shutdown, and rebooted. In addition, snapshots can be taken, deleted and restored remotely via the browser. Howtoforge.com goes over the installation of PHPVirtualbox in this short article.

Validate IP Addresses in PHP

Let’s say you were given a task to validate an IP address in a custom script. One approach is to use regular expressions and use pattern matching to see if user input is correct or not. In this example, we will use a regular expression below to validate IP addresses.

We assume user input is done via a form. First things first, we need to sanitize the input. Once sanitized, we can then test the input against the regular expression using a PHP function called the ereg().

// the regular expression for valid ip addresses
$reg_ex = '/^((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))*$/';
// sanitize input from form
$ip_address = addslashes(htmlspecialchars(strip_tags(trim($_POST['ip_address']))));
// test input against the regular expression
if (ereg($reg_ex, $ip_address)) { 
   // ip address is valid
} else {
   // ip address is not valid

The result is, we now have a facility to check the validity of IP addresses. We can now perform additional steps when the IP address is valid, or display errors if the IP address is invalid.

MySQL mysql_connect new_link

I want to share a database connection access problem I had last week, while working with a custom PHP script inside WordPress. I had created this WordPress Page Template containing some PHP code that needs access to the database. The problem was that the database connection for my custom script overwrote the WordPress database connection that was previously establish, causing certain parts of WordPress to not display properly.

It took me a while to figure out that it was the newer database connection of my custom PHP script that was causing the previously established WordPress database connection to disappear. Hence, certain parts of the WordPress page were not displayed. Little did I know, that the fix was quite simple. So, here’s a sample of my mysql_connect code. Prior to this line, I’ve already set the variables.



The Fix

Simply add a fourth parameter called new_link and set it to TRUE.


What this does is basically telling mysql_connect to establish a new connection, while keeping the older mysql_connect connection around, in case we need to access it at a later time. It’s amazing how one little switch in a command can make a huge difference to this seemingly simple code. Anyways, adding a fourth parameter and setting it to TRUE was the solution.

Calculating Dates in PHP

Displaying dates in PHP is a no brainer. You simply echo the date() function to display the current date. For example, echo date(‘Y-m-d’) will display the current date in the ISO date format of ‘2012-02-27.’ However, calculating dates in the past or in the future is a tiny bit more tricky. For accuracy, I recommend that you use mktime(), which converts time to Unix timestamp. You can then perform date calculations in Unix timestamp which is much more accurate. You do have the option to change the format back to ISO, if you desire. Here are a few examples.

Display the current date:

echo date('Y-m-d');

Output: 2012-02-27

Convert to mktime:

$t = mktime(0, 0, 0, date("m"), date("j"), date("Y"))

Display the start of the current month:

echo date('Y-m-d', mktime(0, 0, 0, date("m"), 1, date("Y")));

Output: 2012-02-01

Display the end of the current month:

echo date('Y-m-d', mktime(23, 59, 59, date("m")+1, 0, date("Y")));

Output: 2012-02-29

Display the start of last month:

echo date('Y-m-d', mktime(0, 0, 0, date("m")-1, 1, date("Y")));

Output: 2012-01-01

To display the end of last month:

echo date('Y-m-d', mktime(23, 59, 59, date("m"), 0, date("Y")));

Output: 2012-01-31

Display the start of next month:

echo date('Y-m-d', mktime(0, 0, 0, date("m")+1, 1, date("Y")));

Output: 2012-03-01

Display the end of next month:

echo date('Y-m-d', mktime(0, 0, 0, date("m")+2, 0, date("Y")));

Output: 2012-03-31

This code is very flexible. If you like to display the dates to any other format, you can change the date format to any format that you like. Check out all the different date formats. I hope this was helpful.

Demand For Mobile Developers

The number of users accessing the Internet will double by 2016. The driving force behind the numbers are the emerging markets. Most of these new users will access the web via mobile phones.

Currently, there are 3 billion Internet users, according to Google. There are 200 million new Internet users every year. About 80% of the new users access the web via mobile phones.

What this means is, there are plenty of opportunities for mobile developers. Remember the good old days when blocks of ice were sold by the thousands by ice manufacturers. They made a handsome profit back then.

But, the arrival of the refrigerator forever changed the landscape. Companies simply folded and moved on to something more profitable. It will be the same story for many technologists today.

The shift is on. Mobile development will be on the rise. There will be a huge demand for mobile developers. It’s time for many of us to change gears.

CodeIgniter Form_Dropdown

I had a little problem using CodeIgniter’s form_dropdown the other day. Form_dropdown produces an output similar to HTML’s form select option. I was trying to retrieve data queried from a database and display the result in a form. Well, after several test and trials, I finally got the script to work. Here’s how I did it.


The form_dropdown function typically has 3 options. The first option is the fieldname. The second option is the option data usually laid out in an array. The third is the selected data.

form_dropdown(‘name’, array(1?=>’one’,2?=>’two’,3?=>’three’),1);

This produces:

<select name=’name’>
<option value=”1? selected=”selected”>One</option>
<option value=”2?>Two</option>
<option value=”3?>Three</option>


In CodeIgniter, I have a simple script that stores bookmarks. I categorize my bookmarks using tags. When adding bookmarks, I call on the get_dropdown_tags function in Models to retrieve all the tags and display them in array that I can use with form_dropdown. Here are my CodeIgniter entries.


$data['tags'] = $this-&gt;links_model-&gt;get_dropdown_tags();


function get_dropdown_tags() {
  $tags = $this-&gt;db-&gt;query('select distinct tag from links');
  $dropdowns = $tags-&gt;result();
  foreach ($dropdowns as $dropdown) {
    $dropdownlist[$dropdown-&gt;tag] = $dropdown-&gt;tag;
  $finaldropdown = $dropdownlist;
  return $finaldropdown;


In views, I’m simply calling the form_dropdown function using the $tags array passed on by the controller. It’s a pretty neat way to recall data from a database and outputting them in form_dropdown.


Finally, a dropdown list that works.