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 »
Making WordPress XHTML Strict Compliant
Posted in Tech
Afternoon watch, 3 bells (1:46 pm)

There are two obstacles in making WordPress, even the most current version, XHTML Strict compliant. Today I discovered the second one, when you use the relatively new Gallery feature.

To fix this problem, you need to eliminate an inserted style tag from the wp-includes/media.php file. The chunk looks like this (mine is found on line 426):

<style type='text/css'>
	.gallery {
		margin: auto;
	}
	.gallery-item {
		float: left;
		margin-top: 10px;
		text-align: center;
		width: {$itemwidth}%;			}
	.gallery img {
		border: 2px solid #cfcfcf;
	}
	.gallery-caption {
		margin-left: 0;
	}
</style>

Copy this to your theme's style.css stylesheet, replacing the call to $itemwidth with width: auto;. Delete the offending code from media.php.

Every time you upgrade, you'll have to repeat this process. That is, until the WordPress developers make their code XHTML Strict compliant, which may never happen.

The second obstacle to a nice, XHTML Strict weblog is the link code. Get a copy of my strict_links.txt widget, rename it, and add it to your widgets directory. Use it instead of the normal links widget.

2 Comments »