Almost Reformatted
Posted in Tech
Afternoon watch, 4 bells (2:05 pm)

I almost had to reformat a Windows 7 machine today that wouldn't recognize the primary drive or the copy of Windows installed on it. Running the repair option from the DVD saw the secondary drive and gave me no option to fix the master boot record. Opening a command prompt (again, using the Repair section of the DVD) defaulted to the D: drive, but allowed me to change to C: and view files just fine.

So my first though was to fdisk /mbr the thing, but fdisk is no longer part of Windows. That gave me a sad. Fortunately, there's a new alternative: bootsect /nt60 c: /mbr

Running that and rebooting took me right back to the installed operating system, so saving itself from a pending reformat.

Leave a Comment »
Apache and PHP Extensions in Windows
Posted in Tech
Forenoon watch, 6 bells (11:28 am)

I've been fighting an error with my PHP installation in Windows with Apache related to loadable extensions. In my error log, I kept getting the errors:

PHP Warning: PHP Startup: Unable to load dynamic library 'c:\\Program Files\\PHP\\ext\\php_mssql.dll
PHP Warning: PHP Startup: Unable to load dynamic library 'c:\\Program Files\\PHP\\ext\\php_pdo_mssql.dll

Interestingly enough, if I ran PHP through the console, it loaded PDO and mssql just fine, the problem was only with the environment in Apache. Turns out the ntwdblib.dll wasn't being located by Apache. I could probably have added the PHP path to the environment variable PATH, but the easiest solution was to copy the dll to the Windows\System32 directory. A restart of Apache after that cured the problem.

Leave a Comment »
PHP, PDO, and MSSQL in Windows
Posted in Tech
Last dog watch, 1 bell (6:33 pm)

If, like me, you've been using PHP's PDO via the MSSQL driver, be aware that newer versions of PHP do not support MSSQL natively. Microsoft has it's own PHP driver now, or you can use the FreeTDS MSSQL extension, but I strongly recommend just switching to use the provided ODBC and PDO_ODBC extensions and save yourself the trouble. If you're already using PDOs, then you just have to create the object a little differently. For example:

$sql = new PDO("odbc:Driver={SQL Native Client};Server=ip.add.re.ss;Database=dbname;Uid=user;Pwd=password");

That worked for me. Not sure what you can do about the old mssql_guid_string function if you need that, though. I have the FreeTDS lib installed as well and that lets me call it, until I figure out how to do the same thing in ODBC.

Yes, ASP fans, that's a ONE LINE connection to a database. That's all anyone should need!

Leave a Comment »