PHP stands for PHP HyperText Processor (it’s what’s called a recursive acronym). PHP is an open source scripting language widely used for server-side web development.

Install the PHP SQLSRV Driver on Linux

Rejoice! Microsoft actually does provide a PHP Linux driver for Microsoft SQL Server. The bad news is, it can be a real pain to get it working.  I went through this experience tonight while setting up a utility I wrote for a client. I ran into two separate issues. This article provides some assistance with the issues I ran into when I tried to Install the PHP SQLSRV driver on Linux.

How to Install PHP SQLSRV Driver on Linux

The instructions in the repository’s are actually pretty good. Check out the official Github repository for the driver for the latest version and installation information. I recommend you follow their instructions first. When you hit a roadblock, come back to this article for help.

PECL Building with Wrong PHP Version

The final step in the installation is installing the base driver and the PDO variant withpecl install. PECL runs a build process on your machine and it uses a tool called phpize to execute the build. The version of this tool needs to match your PHP version. Otherwise, the build will succeed, but the extension file it generates won’t be compatible with the version of PHP you’re running. You’ll know pretty quickly if this is the case if you get “can’t load extension” errors after you build and execute PHP.

To solve the problem, install the version of phpize that matches your PHP version. For example, if you are running PHP 7.1, you would run:

sudo apt-get install phpize7.1

Microsoft ODBC Client is Missing

After I fixed the problem above, I ran my PHP script and the database connection failed. The PDO SQL Server driver reported an error message that it could not execute because it required the Microsoft ODBC Client. Installing the client is actually part of the steps in the instructions provided on Github. But for me, the installation failed and I didn’t notice. I went back and repeated this step and found that there was a missing dependency that would not install. Once I manually installed it and re-ran the client installation steps, then the PDO driver started working.

The Github repository below contains the official drivers from Microsoft. Check out the repository for the latest version information and installation instructions.

Microsoft Drivers for PHP for SQL Server
291 forks.
1,353 stars.
20 open issues.
Recent commits:

Subnet Calculator in 9 Lines of PHP

I’ve been spending a lot of time studying for my Microsoft 70-642 exam, an important part of which is subnetting.As an intellectual exercise I wrote a subnet calculator. Enjoy:

 function subnet($hosts)
	$bits       = decbin($hosts) + 2; // Add 2 for Network ID and Broadcast
	$hostBits   = strlen($bits); // find how many bits it takes to represent it
	$cidr       = 32 - $hostBits; // Find slash-notation
	$binaryMask = str_repeat('1', $cidr) . str_repeat('0', $hostBits); // Subnet in binary
	$subnet     = implode('.', array_map('bindec', str_split($binaryMask, 8))); // Subnet in dotted-decimal
	return array('hosts' => $hosts, 'hostBits' => $hostBits, 'cidr' => '/' . $cidr, 'binaryMask' => $binaryMask, 'subnet' => $subnet);

6 Reasons I Chose A2Hosting

FTC Disclaimer: I’m a satisfied, four-year customer of A2Hosting and a proud member of their Affiliate Program. I’ll make a buck or two if  you purchase hosting via my site,  so if you have a moral objection to helping me pay my monthly Netflix subscription, then by all means don’t click my links. Either way, check out A2Hosting.

Anti-Disclaimer: My blog has had a long and proud tradition of sounding off about products that suck. Just this once I decided to get behind a product that I’m truly proud of and tell you all why I recommend A2Hosting’s Shared Hosting package above the competitors.


If one goes searching this vast Internet of ours for recommendations about cheap web hosting, one will be sure to drown in oceans of fake ratings and user reviews, not to mention affiliate links from folks who have never actually sampled a company’s services or those of any of their competitors.

I’ve dealt with several cheap, shared web hosts from the largely unknown Global Internet Solutions (name intentionally left unlinked for your protection) to Danika Patrick’s host-of-choice GoDaddy.  But when I have the choice, I host with  This personal choice and my recommendation to my readers comes not from the promise of affiliate payments, but from four years of positive experiences with this company. Below are 6 reasons why I stand behind A2Hosting.

6. A2Hosting Watches & Listens

Up until just a few months ago I was running a now-defunct personal project called Sudoku Madness.  This marginally-popular website was hosted on A2Hosting and hosted hundreds of thousands of unique Sudoku puzzles in a PostgreSQL database. My site became a small hit (especially with my sister’s seventh-grade math class), which turned out to be a problem for other users who shared my server:  my scripts were opening a new database connections on each request and not returning them for use by other users.  A2Hosting didn’t knock me offline as they had every right to do, but they immediately notified me that my PHP was running amock and proposed a fix.

A2Hosting solved a problem of my own creation and suggested a solution that kept me and their other customers online and happy. Plus they kept me earning literally tens of cents per week in affiliate income from that project! (Look for my money-making infomercial coming soon to QVC!)

5. A2Hosting Supports PostgreSQL

Many shared web hosts support only the typical LAMP development stack; but in addition to the traditional Mysql offering, A2Hosting also supports PostgreSQL.  Attempting to debate the pros and cons of the two platforms is both out of this article’s scope and risks inciting a religious war, but suffice it to say that Oracle’s purchase of Sun Microsystems leaves MySQL’s future uncertain so a choice in open database platforms can’t be a bad thing.

I chose to use PostgreSQL on several of my projects, most notably on my Sudoku Madness site.  That particular database housed hundreds of thousands of records and used home-brewed PGSQL procedures to speed up searches and puzzle creation. The site ran for several years largely unchanged, and speed and storage never became a factor.

My one complaint: A2Hosting’s automatic backups include your MySQL databases, but at least as of a year ago, not your PostgreSQL databases. To the best of my knowledge, you’ll need to set up your own backup schedule if you choose PostgreSQL (a good idea regardless).

4. A2Hosting’s Server Rewind Feature

Whether you only host your own projects or resell hosting to clients, the day can and will come when you’ll need a backup. There is nothing more embarrassing and damaging to your credibility than losing a client’s site or database and not having a recent backup.  Nobody is perfect. That’s why pencils have erasers and decent web hosts provide backups.

I’ve tested A2Hosting’s backup system on numerous occasions.  The first was when my account was migrated to a new server and one of my databases was missed during the restoration (again, darn that lack of PostgreSQL backups!). With the help of A2Hosting’s support department I was able to recover one of my manually created SQL dump files from the Server Rewind app and quickly get my site up and running again.

More recently a site which I inherited from another developer was hacked.  The code for this site only worked when a certain directory under the web root had full write access by the Apache process and the client refused to pay for a rewrite.  Suffice it to say, they eventually got theirs.  I was able to recover both their site and their back-end database  using Server Rewind, available through my management panel.

3. A2Hosting Supports Subversion

The day comes when a developer outgrows manually updating their websites via FTP.  Fortunately A2Hosting supports Subversion over SSL, which provides you with secure version control of your code.  They also offer CVS and Git hosting if Subversion isn’t your thing.

I personally use A2Hosting’s Subversion hosting for all of my projects that aren’t based on another project (WordPress, etc), even development projects that aren’t hosted on A2Hosting.  After committing my code to Subversion I SSH into my server and run a script that pulls the latest changes from the repository. Using version control to manage your sites saves you time and bandwidth by only uploading changed files, and it gives you the power to quickly undo a bad update.

2. A2Hosting Has Never Eaten My Domains

Granted, I’ve never given them the option. I’ve previously lost domains to other shared web hosts who offered me cheap domain registration but refused to release my domains after I became disgusted with their service and wanted to move.

On the other side of the coin, I’ve transferred a number of domains to A2Hosting and they’ve always offered assistance in this frustrating process when they can.

1. A2Hosting’s Support is Unmatched

I can’t begin to explain how helpful A2Hosting has been to me over the past few years.  They’ve always responded quickly to my support requests no matter how inane, and they’ve saved my ass from embarrassment and lost clients on a number of occasions.

When I developed my first site using PostgreSQL, I uploaded my scripts to A2Hosting only to find that they had not enabled the pdo_pgsql extension which my code was completely dependant upon.  Their support people had the issue resolved within hours, which I consider more than acceptable for a shared host, when other hosts have rejected my requests across the board for common PHP extensions in the past.

More recently I had an issue with mail from my domains being rejected.  This is the sort of issue which truly tests a company’s metal because there are so many possible points of failure. Many companies will play the blame game for days or even weeks with email issues, insisting that the problem is “on the other end.” A2Hosting has never been afraid to dive in, and resolved this issue by the end of the day.


Though A2Hosting remains competitive in price, speed and options, their edge comes from their fanatical support.  Though I award them zero points for originality by naming their support wing the Guru Crew, those are the folks who have made me a committed and loyal customer of A2Hosting. Choosing a web host is a lot like choosing car insurance:  you can pay your premiums for years and have no concept of a company’s quality.  You find out when it’s too late, and that’s when A2Hosting truly shines.

PHP On Windows 7

Last week I decided to take the plunge and install the release candidate of Windows 7 on my office workstation where I happen to do a lot of web development and testing.  My development stack consists of Netbeans IDE, PHP 5.2.8, and IIS 7.  There are plenty of other quality tutorials out there explaining how to get PHP working on IIS 7 so I won’t bother beating that particular dead horse.  However there was one quirky difference between installing PHP on Vista and installing PHP on IIS 7 that developers may want to be aware of before they follow my lead.

The Problem : Editing php.ini as a Standard User

During the process of installing PHP on Windows 7 you will be required to copy php.ini into the C:\Windows directory, and  later point you’ll most likely need to edit this file to suit your needs.

On Windows Vista I simply wasn’t allowed to edit files under the \Windows directory (specifically php.ini) when logged in as a Standard User. Windows 7 was more than happy to allow me to modify and save this file in the same location, logged in with the same credentials. But even after restarting IIS my configuration changes never took effect.

The problem was caused by something called the Virtual Store, an application compatibility feature that existed in Windows Vista but works a little bit differently in Windows 7.  Where Vista wouldn’t let me edit this file at all, Windows 7 happily lets me modify it but transparently saves the changes in a different location. The updated php.ini was stored in %UserProfile%\AppData\Local\VirtualStore\Windows\php.ini.  The service account which IIS runs under can’t see this updated file

The Solution: Run As Administrator

When editing php.ini, don’t simply double-click it and make changes.  You must run your text editor as an administrator to edit the file, otherwise the changes will be saved to the Virtual Store.