Thursday, April 19, 2012

PHP Ternary Operator

Ever want a short way to quickly evaluate a conditional and set a variable based on it's result? You could do it the long way and do something like:

if ( $var == 1 ) $moo = 2; else $moo = 3;

Or you could use a ternary operator, for example

$moo = ( $var == 1 ? 2 : 3 );

It evaluates the conditional before the question mark, if it's true it gives you the first item before the colon, otherwise it gives you the item after the colon. This is useful for many situations such as showing a quick representation of a boolean:

echo ( $var ? 'Yes' : 'No' );

It makes booleans more digestible to those users who may not know that a 1 is "Yes", in situations like pulling a boolean value from a table and displaying it to an admin.

Monday, April 2, 2012

windows 7 windows is unable to install to the selected location 0x80300024

Lemon!
Recently my desktop computer had an SSD drive go out. The said SSD had the installation of windows 7 on it. Out of no where the drive would not boot. I tried a few times to get it to boot, eventually it got through and gave me the classic blue screen of death, referencing some problem about disk reads.

After a few more tries I was able to get it to boot, however the system had many corrupted files. This SSD is not even a year old yet. I don't know if I will have much trust for SSD's for a while; on the other hand I have had regular disks go out on me in the same time frame.

At any rate, I had a backup of my files, and as the system had a couple of 2 TB drives I had a place to install win7 to get back up and running. I removed the SSD drive, popped in the Windows 7 install disk and rebooted. I was greeted by the installation screen and the options for choosing a drive. Beforehand I had moved all my files over to one of the drives, and cleared one off in prep to install win 7.

I selected my unallocated drive and hit go, expecting that the install would soon be under way. I was greeted by an error message "windows 7 windows is unable to install to the selected location 0x80300024". Microsoft sure does love their cryptic error messages. After a bit of googling I decided that I'd give a try at loading some drivers from the motherboard driver disk, in a ditch effort that it might be a missing driver. After no luck with the driver and win 7 installer still throwing some 0x80300024 at me.

In another ditch effort, I figure well perhaps the installer is easily confused by me having multiple hard drives. I shut down the system, unplugged the drive that had data leaving only the unallocated drive plugged in. I fired up the windows installer again, clicked the disk, low and behold my installation is underway.

This goes to show you, the windows 7 installer is easily confused. If you are having problems try unplugging all extra disks except the one you are installing to.