How to Fix Internet Explorer + iFrame + PNG Transparency Issue

Working on a client site, we ran into issues with Internet Explorer, iFrames, and transparent PNGs. For the site, we are using an iFrame to load content when the user clicks on a button. On the fly, with javascript, a bit of code gets generated like:

Blah, Blah, Blah

[code]#bazImage {color: white;font-size: 16px;font-weight: bold;padding: 25px 30px 0px 18px;font-family: Arial, Helvetica, sans-serif;background: url(images/bazImage.png) no-repeat;width: 256px;height: 107px;}[/code]

The background image is bazImage.png, a transparent PNG. This worked fine in Chrome, Firefox, and Safari, but all the transparent pixels turned up as white in IE. My first thought was we needed to apply a PNG fix.

But that didn’t help.

Not so surprisingly, Internet Explorer handles transparency differently than other browsers. Elements have an allowTransparency attribute that defaults to false, so embedded iFrames won’t be transparent. Simply set it to true.

One final step, set ‘background-color: transparent;’ in the body element. MVC: Expecting element ‘root’ from namespace ”.. Encountered ‘None’ with name ”, namespace ”. MVC Expecting element 'root' from namespace ''.. Encountered 'None' with name '', namespace ''.

While walking through an MVC3 app, I noticed that Ajax calls resulted in nothing happening. Debugging in Visual Studio, I noticed a SerializationException at the following code:

[code]public override void OnActionExecuting(ActionExecutingContext filterContext) {….object o = new DataContractJsonSerializer(RootType).ReadObject(filterContext.HttpContext.Request.InputStream);}[/code]

The JSON response from the Ajax was supposed to be read here, but it was failing. It was a runtime exception, “SerializationException was unhandled by user code.” Turns out InputStream wasn’t being read from the beginning of the stream, so the JSON couldn’t be deserialized properly.

Resetting the position in the current stream to the beginning should make it readable again:

[code]public override void OnActionExecuting(ActionExecutingContext filterContext) {….//move current position in the stream back to the beginningfilterContext.HttpContext.Request.InputStream.Position = 0;object o = new DataContractJsonSerializer(RootType).ReadObject(filterContext.HttpContext.Request.InputStream);}[/code]

Mac OS X + Eclipse + PDT + MAMP + Xdebug Fun

Today I spent 3 hours trying to setup a new dev environment with debugging on my MacBook, consisting of Eclipse, PDT (PHP Development Tools), and MAMP. Not exactly fun.

The critical part of what I wanted to set up was Xdebug. There are quite a few web designers/developers out there, who simply write code, save, refresh their PHP in the browser, and do a quick visual check. That might work for pretty simple stuff, but it can be hard to find tricky bugs when the web app achieves some level of sophistication. So Xdebug (or any other debugging tools like Zend) is a must for me.

First, you have to set up Eclipse to handle PHP. There are quite a few options here. You can download the many different IDEs based on Eclipse, download Eclipse with PDT, or install PDT as a plugin to an existing Eclipse installation. Since I already Eclipse installed, I decided to install it as a plugin.

In Eclipse, go to Help -> Install New Software.

Select the drop down menu for Work with:

Install Eclipse PDT by Plugin

Select Helios –

Find the Programming Languages option, expand it, scroll down and select PHP Development Tools (PDT) SDK Feature.

Selecting PDT to install in Eclipse

Hit next, agree with the license, etc, etc.

Next, time to set up Xdebug in php.ini. If you installed MAMP in /Applications in Mac OS X, and assuming you want to use PHP 5.3, the php.ini is in /Applications/MAMP/conf/php5.3.

Find the [xdebug] section towards the end of the file, and update it to:

[code][xdebug]zend_extension=”/Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/”xdebug.profiler_output_dir = “/tmp/xdebug/”xdebug.profiler_enable = Onxdebug.remote_enable=Onxdebug.remote_host=”localhost”xdebug.remote_port=9000xdebug.remote_handler=”dbgp”xdebug.idekey=ECLIPSE_DBGP[/code]

Unfortunately, the Xdebug that comes with MAMP didn’t work for me, so I needed to get a more recent version. There are Windows binaries on, but no Mac OS X ones. Turns out Komodo, another IDE, has already compiled binaries of the new versions of Xdebug. Download the Xdebug binaries from Komodo and update the zend_extension path above or replace the

We need to let Eclipse know it should be using MAMP PHP. Go into Preferences -> PHP -> PHP Executables. Edit the default. Change the executable path to the MAMP PHP, something similar to /Applications/MAMP/bin/php5.3/bin/php. Make sure PHP debugger is Xdebug.

Getting Eclipse PDT to Use MAMP PHP Executables

Below PHP Executables is PHP Servers. Lets update this to work with MAMP. MAMP’s default Apache port number is 8888, we’ll set the URL to http://localhost:8888.

Eclipse editing PDT Server to work with MAMP

Let’s make sure that Xdebug is working with MAMP. Create a test PHP file to spit out phpinfo, which lists configuration settings:

Test XDebug setup in MAMP

Go to Run -> Run As -> PHP Web Page. Scroll down a bit in the browser and you should see a reference to Xdebug:

Verifying XDebug Updated in MAMPThe Xdebug version that comes with MAMP is 2.0.x.

Thats it.

Mac OS X: Get Photos Off your iPhone without iTunes

Mac OS X: Get Photos Off your iPhone without iTunes

For the Web Dev Fools podcast, I was taking behind the scene pictures of the intros that were recorded. I ended up with about 20 that I wanted to look at on my MacBook.

There are 4 options of transferring photos from the iPhone to a computer: text message them to an email address, import using iPhoto, email them using the iPhone Mail app, or sync with iTunes. I don’t have a text message plan, so I didn’t want to pay to text myself the pictures. You can’t select multiple pictures to email yourself through the iPhone Mail application. I don’t use iPhoto regularly, so thats a no go. And I don’t sync with iTunes, and I didn’t want to start now.

iTunes not being able to do it natively is irritating. It lets you grab music and movies off the iPhone directly, but not photos. The only option with iTunes is to sync:

Mac OS X: Get Photos Off your iPhone without iTunes

But, Mac OS X does come with the perfect tool to get photos off the iPhone. Its called Image Capture. Simply plug in your iPhone to your Mac, and start Image Capture.

Mac OS X: Get Photos Off your iPhone without iTunesYou will see your iPhone on the left panel, select it and you will see all the photos on the iPhone. You can select individual photos or import all of them. And it gives you the option of selecting a folder where the photos will be placed.


Photo courtesy of Fred.

SQL Server: A network-related or instance-specific error occurred while establishing a connection to SQL Server

I spent pretty much all today wiping a desktop, and installing Windows 7, Visual Studio, and SQL Server Express 2010 on it. Talk about some form of hell.

The WIndows 7 install went fine, The Visual Studio install went fine. The SQL Server Express install went fine. Thought I was in heaven.

Yeah, right.

So I fire up SQL Server Management Studio and this is what I see:

Makes sense, I hit the Connect button. After about 5 seconds, I see get an error:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 2)

For help, click:

Of course the information is correct, I’m on my local box, how can you not connect to it? Bah.
Turns out, I got the server name wrong. It should be either <MACHINENAME>SQLEXPRESS or .SQLEXPRESS.

Then it all works like magic.

Mac OS X Perl: Can’t locate Config/ Error

Perl Screenshot

I ran into an interesting Mac OS X Perl issue the other day. Since @runlevelmedia hosts websites for clients, its a good idea to have a backup strategy. Hoping and prayer is not really strategy.

We have been working on updating our backup plan to make it more efficient. Basically, the script could be run from different machines, so we have multiple copies as a starting point.

Testing out the script on my Macbook threw me for a surprise. Apparently, I mostly use the basic Perl modules pre-installed with Mac OS X and I’d never run across any issues.

[code]jeebus:~ nali$ ./ —config testconfig.iniCan’t locate Config/ in @INC (@INC contains: /Library/Perl/Updates/5.10.0 /System/Library/Perl/5.10.0/darwin-thread-multi-2level /System/Library/Perl/5.10.0 /Library/Perl/5.10.0/darwin-thread-multi-2level /Library/Perl/5.10.0 /Network/Library/Perl/5.10.0/darwin-thread-multi-2level /Network/Library/Perl/5.10.0 /Network/Library/Perl /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level /System/Library/Perl/Extras/5.10.0 .) at ./ line 3.BEGIN failed—compilation aborted at ./ line 3.[/code]

(Yes, my Macbook name is jeebus). Quick Googling found people complaining about the Perl version installed by Mac OS X. The problem is that its not the best idea to yank out the pre-installed version because a lot of apps and systems related processes expects it all work in a certain way. One example I saw was how iTunes used a string comparison behavior that got changed in the more recent versions of Perl. So lots of folks end up installing a bunch of different versions of Perl, which is beyond confusing and unmanageable.

Turns the following command makes it pretty easy to install specific CPAN modules:[code]sudo perl -MCPAN -e ‘install Config::IniFiles’[/code]

Another option is to kick off a CPAN shell and install that way:[code]sudo perl -MCPAN -e ‘shell’Terminal does not support AddHistory.cpan shell — CPAN exploration and modules installation (v1.9205)ReadLine support available (maybe install Bundle::CPAN or Bundle::CPANxxl?)cpan[1]> install Config::IniFilesCPAN: Storable loaded ok (v2.18)Going to read /Users/nali/.cpan/Metadata….[/code]

That’s it!