MSSQL Driver for PHP5.3

Before using PHP5.3, I never had to worry about MSSQL support. PHP included a dll file to use with MSSQL Server 2000 and up. This is no longer true if you decide to upgrade to PHP5.3.x. For months I looked for ways to connect to our MSSQL Server using PHP5.3.x. I finally found the driver and it works. It’s called SQLSRV and you can download it from http://sqlsrvphp.codeplex.com. It’s easy to install, just read the CHM file.

  • Run the exe to unpack it
  • Rename the folder to Microsoft SQL Server Driver for PHP (optional)
  • Move this to your %Program Files% directory (optional)
  • Inside that directory you will find several dll files. It supports both NTS (Non Thread Safe) and TS (Thread Safe). You also need to choose between VC6 or VC9 compiler. This will determine which file will be used.
  • Copy that file to %Installation Directory%\PHP\ext\ (assuming you are using the ext directory for your extensions.
  • Edit your php.ini. In the extensions section add the following extension=php_sqlsrv_53_ts_vc6.dll – or whatever file you copied to your ext directory.
  • Restart your web server and that should be it.

Here’s a quick sample code to get you started.

<?php

$servername = "SQLSERVER_NAME_OR_IP";
$uid = "db_username";
$pwd = "db_passwd";
$connectionInfo = array (
"UID"=>$uid,
"PWD"=>$pwd,
"Database"=>"database_name"
);
$conn = sqlsrv_connect($serverName, $connectionInfo);

if ($conn === false) {
echo "ERROR: DB Connection";
die(print_r(sqlsrv_errors(), true));

}
$stmt = sqlsrv_query($conn, "SELECT * FROM table");

if ($stmt) {
while ($row = sqlsrv_fetch_array($stmt)) {
echo $row[0].’<br />’;
}
}

?>

That should do it. I have only tested this on Windows 7 Professional (32bit), MSSQL 2005 (32bit) Standard on a remote Windows 2008 Server Standard R2, PHP5.3.3, Apache2.2.15, and driver version 1.1 (version 2 is now available) . Make sure your MSSQL server can accept remote connections if it is on a different server than your web server. The above instructions shouldn’t be  too different on other versions.

If you have a phpinfo() page, you will see the image below.

sqlsrv_phpini

Hope this helps you get started. Happy coding.

Sony PSP Go

My mother-in-law bought me a PSP Go for Christmas, thanks Mommy! I’ve had for almost a month now. So far it’s great. But first, let me just say that I came from a PSP 2000. I love the console but I didn’t play it as much so I sold it last year. Now the PSP Go comes out and I started to miss my PSP. I had a choice between the PSP 3000 or the Go. So I spent a few days to weeks trying to figure out which to get. I heard both sides and I have my reasons.

Here are the reasons not to get the PSP Go and some notes as to why I still went with the PSP Go.

  1. More expensive. (It’s free for me since it’s a gift.)
  2. Can’t sell downloaded games when you’re done with them as oppose to old UMD games. (I never sold any of my UMDs either even after I was done with them.)
  3. Not all games are available for download. (I’m more of a classic guy. I like playing older titles.)
  4. New games aren’t available the same day as UMD versions are released. (As I stated above, the new titles aren’t such a big deal to me. I have a PS3, Wii, 360, iPhone, Google OS phone – so the PSP won’t be my primary gaming console let alone the only portable gaming console I have.)
  5. Frequent deals on UMD version games versus the downloaded games. (See #4 and I’m a patient person.)
  6. The controls are awkwardly placed. (As with any new console, we all have to get used to the newly shaped controller. You can also use the “claw” position when playing the PSP.)
  7. Smaller screen size. (No big deal for me.)
  8. 802.11 B only. (I know it doesn’t support at least G or N, I doubt the PSP can process that big of information even if it did. Also, Sony’s servers are slow most of the times, even if it had the capability of 54mbps, I doubt you’ll be downloading at that speed anyway.)

Here are reasons why I like the PSP Go over the old series.

  1. Smaller. It’s more portable and fits easier in my pockets.
  2. Lighter. Not that much lighter, but lighter.
  3. Downloaded content. I hated UMDs. I hated carrying them around. I’ve lost too many in the past. With downloaded content, I don’t have to worry about losing games. I can re-download them.
  4. Bluetooth. You can connect headsets and the PS3 controller.
  5. Pause a game any time. This feature is great. I can pause a game any time without having to look for a saving point. Of course you can only do this one game at a time.
  6. 16GB internal memory. It’s plenty to begin with. I’ve downloaded a few games and demos and still have 10GB of space left.

Other things I noticed.

  • It took a little over 2 hours to download God of War (1.3GB) and 34 minutes to install. If you have a PS3, use it to download the content and extract – it is so much faster.
  • Downloading content from PSN is noticeably slow whether on my PS3 or PSP.
  • There is no L2 or R2 buttons on the PSP. You may run into problems with PS1/2 games such as Twisted Metal and the Street Fighter Alpha series – they use L2 and R2 buttons. You may have to reassign them.
  • When connected to OS X, it mounts as if it’s an external storage device. Transferring data shouldn’t be a problem. No official software from Sony is available if you want to use your Mac and download from the PSN website (of course).

So far I like it. Many others don’t like it but for what I need and use it for, it fits me just fine. Here are a few pics next to the old PSP.