RSS
 

Archive for the ‘Languages’ Category

PHP intermittent blank page

30 Mar

There is a problem with IE and PHP applications is certain instances where an intermittent blank page appears instead of the expected content.

This seems to relate to an earlier bug reported by Microsoft with IE 6 where the content length was reported as 0 during POST requests. This occured when browsing sites running UNIX/Apache with keepalive enabled. However, I’ve discovered that the same problem occurs intermittently with certain PHP applications and GET requests.

One workaround which solves the problem (although with a performance hit) is to create an .htaccess file in the root directory with the following setting:

[code]
BrowserMatch "MSIE" nokeepalive downgrade-1.0 force-response-1.0

SetEnvIf User-Agent ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
[/code]

This workaround disables keepalive for all IE 6 clients. I imagine this would have a negative performance effect, however it is likely preferable to a buggy application.

I haven’t been able to determine if certain PHP code techniques could be causing the problem. I read certain people presuming that it could be session related, however, i went as far as removing all session functionality from an application, however it did not solve the problem.

 
4 Comments

Posted in *NIX, Apache, PHP

 

PHP directory name is invalid

30 Mar

Certain PHP applications return the error “directory name is invalid” when installed on a windows server. This seems to be an issue with IIS and certain PHP versions.

A workaround is to open the IIS Admin panel, go to the MIME configuration for .php files and make sure that “Check that file exists” is enabled. This seems to resolve the problem.

Additionally, check that IUSR account has read permissions on the directory (check both IIS and NTFS settings).

 
No Comments

Posted in PHP

 

.NET controls don't display formatting correctly in FireFox

30 Mar

If you’re writing .NET applications, when you test them in FireFox, they may look totally different than in IE. The first thing you probably notice is that input boxes are all the default width. Anything that you’ve resized in the designer doesn’t display in FireFox. If you use the Visual Studio designer to resize controls, when you look at the source, you’ll see that this is all done with the style attribute and not using width/height attributes.

The reason that this is happening it turns out is that .NET doesn’t recognize FireFox as a modern browser and is “dumbing down” the html output. It’s removing all the style attributes because it doesn’t know if FireFox can handle them.

Luckily, this is one of those problems that has a quick fix, as it turns out. All you have to do is tell .NET how to identify FireFox. In the old days of classic ASP, there was a file on the server called browscap.ini that contained all of this information. For .NET apps, there’s a couple of places to configure the info. machine.config has settings using for the entire server. If you don’t have access to this file, you can even put it in your web.config file just for your app.

Today is really your lucky day because Rob Eberhardt has already created the browser identification code and you can just copy/paste it. The code is found at his site [url]http://slingfive.com/pages/code/browserCaps/[/url]

Rob’s page explains it all but in brief, just download his BrowseCap code and copy/paste it in your web.config file just above the </system.web> tag.

 
No Comments

Posted in .NET

 

Could not load type Foo from assembly NHibernate

30 Mar

This error indicates that the class could not be found when NHibernate is initializing. The key here is “from assembly NHibernate” The reason I was getting this error is because I didn’t realize that you have to specify not only the name of the class (including the namespace prefix), but also the assembly name after the class. I would have thought that NHibernate would have known the assembly name since I was giving it the full namespace, but apparently this is not the case.

For example:

[code:1:441355f572]
<class name="myassembly.model.Foo" table="foo">
[/code:1:441355f572]

This is not enough information. You must also specify the assembly name, or else NHibernate uses the default assembly name of "NHibernate" It should really look like this:

[code:1:441355f572]
<class name="myassembly.model.Foo,myassembly" table="foo">
[/code:1:441355f572]

myassembly would typically being the name of your .NET project. In this case, all objects are being organized in the namespace myassembly.model.

this also applies when mapping relationships:

[code:1:441355f572]
<many-to-one name="child" column="child_id" class="myassembly.model.Child" not-null="true"/>
[/code:1:441355f572]

should be:

[code:1:441355f572]
<many-to-one name="child" column="child_id" class="myassembly.model.Child, myassembly" not-null="true"/>
[/code:1:441355f572]

 
No Comments

Posted in .NET

 

set php allow_call_time_pass_reference in .htaccess

30 Mar

I just spent about an hour trying to figure this out, but when you have a php application that requires call time pass reference to be enabled, you can set in the .htaccess file.  The trick on some systems is that it must be set to “1″ and not “on” as is indicated on the PHP support forums. here’s the code:

php_flag allow_call_time_pass_reference 1

Whether or not you need to use “1″ or “on” seems to depend on the install and whether you’re using PHP version 4 or 5.

 
8 Comments

Posted in Apache, PHP