User Name
Password
AppleNova Forums » Programmer's Nook »

IE sucks and PHP isn't working


Register Members List Calendar Search FAQ Posting Guidelines
IE sucks and PHP isn't working
Thread Tools
Kraetos
Lovable Bastard
 
Join Date: Dec 2005
Location: Boston-ish
 
2006-08-29, 00:40

I have two separate problems. Of course, the first problem arose when I was trying to solve the first problem, so I'll start with that one.

I'm writing a new website and theres a small part of the stylesheet that doesn't work in IE - big surprise. Rather than rewrite my entire stylesheet I've decided to include a small embedded stylesheet that removed the affected div entirely. I was going to make this stylesheet embed ONLY if IE is detected, which brings me to my first problem:

My PHP config either doesn't contain a browscap.ini file or the php.ini file isn't pointing to one.

So I emailed my webhost and asked them to fix this for me. They said they don't support any changes to their default PHP config and if I wanted to customize something I would have to install one myself.

So I dropped a script on my server to install PHP 4.4.2 on my server (no PHP 5, it breaks my links for some reason...), ran it, and wrote the .htaccess file. It didn't work. Any page with a .php file extention on my website is going to a 404 page.

SOOOO... I have two options.

1) I could attempt to fix my PHP install, but to be honest, I am new to a lot of this and I wouldn't even know where to start.

2) Delete the .htaccess file and thereby use the preinstalled PHP 4.4.2 alread provided by my host. But then, I would need to use some other method of browser detection. (Javascript would work but javascript is client-side and therefore less reliable.)

I don't need a complicated browser detect - all I need to know is when I hit an IE user.

Which of these options makes more sense? And, if I should try and use my own PHP install, how do I proceed from here?

Sadly, being a technology pundit is truly never having to say you’re sorry. You can be wrong for years and never lose your job.—The Macalope
  quote
ast3r3x
25 chars of wasted space.
 
Join Date: May 2004
Send a message via AIM to ast3r3x  
2006-08-29, 05:18

You probably want to use conditional comments. I think they only work in IE, but that is really the point isn't it?

Code:
<style type="text/css"> @import "/inc/css/calendar.css"; @import "/inc/css/stylepicker.css"; <!--[if IE]> #problemdiv { display: none; } <![endif]--> </style>
Anything you put in there should only work in IE. I'm not sure if you need to put specific versions or not...as in [if IE 6], [if IE 5]. But I don't think so...although you can.


Anyways, if you want to use PHP, why can't you use $_SERVER['HTTP_USER_AGENT']?

Last edited by ast3r3x : 2006-08-29 at 05:24.
  quote
rollercoaster375
Senior Member
 
Join Date: Mar 2005
Location: UIllinois (Champaign, IL)
Send a message via AIM to rollercoaster375 Send a message via MSN to rollercoaster375 Send a message via Yahoo to rollercoaster375 Send a message via Skype™ to rollercoaster375 
2006-08-29, 09:16

What's in the .htaccess?

Last edited by rollercoaster375 : 2006-08-29 at 09:58. Reason: Clarity.
  quote
mooty
Senior Member
 
Join Date: Jan 2005
Location: London, UK
 
2006-08-29, 09:31

.htaccess configuration files are an Apache thing which allow you to assign custom 404 errors, password protect things, yadda yadda... wikipedia should have a good page on it
  quote
rollercoaster375
Senior Member
 
Join Date: Mar 2005
Location: UIllinois (Champaign, IL)
Send a message via AIM to rollercoaster375 Send a message via MSN to rollercoaster375 Send a message via Yahoo to rollercoaster375 Send a message via Skype™ to rollercoaster375 
2006-08-29, 09:58

Oh, I know what .htaccess is. I was asking what he had in his
  quote
mooty
Senior Member
 
Join Date: Jan 2005
Location: London, UK
 
2006-08-29, 10:00

lol - oh well - it might help someone

Your post still reads strangely to me tho :P
  quote
Kraetos
Lovable Bastard
 
Join Date: Dec 2005
Location: Boston-ish
 
2006-08-29, 12:55

Not much.

In fact, that might be the problem.

There are only two lines in my .htacccess file, they are:

AddHandler phpFour .php
Action phpFour /cgi-bin/php.cgi
  quote
spikeh
BANNED
 
Join Date: Jan 2006
Location: UK
Send a message via AIM to spikeh Send a message via MSN to spikeh  
2006-08-29, 13:34

How unhelpful would it be, on a scale of 1-10 (where 10 is very unhelpful and 1 is only a little bit unhelpful), for me to suggest you scrap the entire project, and start over in Ruby on Rails?

  quote
Kraetos
Lovable Bastard
 
Join Date: Dec 2005
Location: Boston-ish
 
2006-08-29, 13:51

Quote:
Originally Posted by spikeh View Post
How unhelpful would it be, on a scale of 1-10 (where 10 is very unhelpful and 1 is only a little bit unhelpful), for me to suggest you scrap the entire project, and start over in Ruby on Rails?

About a 2. And half of that 2 is because its already preinstalled on my server

Going back to PHP, would this do the trick:

[PHP]<style type="text/css">
<?php

$_SERVER['HTTP_USER_AGENT'] = $browser;
if (stristr ($browser,"msie")) {
require 'css/navoverride.css'; // the CSS required to kill the IE-offending div is here
}

?>
</style>
[/PHP]

If so, it would save me a whole lot of trouble. Thanks for the tip, ast3r3x!

Sadly, being a technology pundit is truly never having to say you’re sorry. You can be wrong for years and never lose your job.—The Macalope
  quote
ast3r3x
25 chars of wasted space.
 
Join Date: May 2004
Send a message via AIM to ast3r3x  
2006-08-29, 16:57

Why don't you want to use conditional arguments and save yourself all the PHP trouble?
  quote
Kraetos
Lovable Bastard
 
Join Date: Dec 2005
Location: Boston-ish
 
2006-08-29, 17:24

Quote:
Originally Posted by ast3r3x View Post
Why don't you want to use conditional arguments and save yourself all the PHP trouble?
Because at the moment, I have no way to test it. Parallels still doesn't work on a Mac Pro and I shipped my Windows box is gone. On the other hand, I can change the HTTP_USER_AGENT with Shiira.

Maybe once Parallels has Mac Pro support, I'll try that out.

Sadly, being a technology pundit is truly never having to say you’re sorry. You can be wrong for years and never lose your job.—The Macalope
  quote
mentholmoose
New Member
 
Join Date: May 2006
 
2006-09-01, 09:30

Quote:
Originally Posted by Kraetos View Post
About a 2. And half of that 2 is because its already preinstalled on my server

Going back to PHP, would this do the trick:

[PHP]<style type="text/css">
<?php

$_SERVER['HTTP_USER_AGENT'] = $browser;
if (stristr ($browser,"msie")) {
require 'css/navoverride.css'; // the CSS required to kill the IE-offending div is here
}

?>
</style>[/PHP]
It looks correct, except I think you need to switch $browser and $_SERVER['HTTP_USER_AGENT']. Also, I think that require() will automatically include the 'css/navoverride.css', whether the person is browsing with Internet Explorer or not. I think this should work correctly.

[PHP]<style type="text/css">
<?php

$browser = $_SERVER['HTTP_USER_AGENT'];
if (stristr ($browser,"msie")) {
include('css/navoverride.css'); // the CSS required to kill the IE-offending div is here
}

?>
</style>[/PHP]
  quote
Kraetos
Lovable Bastard
 
Join Date: Dec 2005
Location: Boston-ish
 
2006-09-01, 15:39

Quote:
Originally Posted by mentholmoose View Post
It looks correct, except I think you need to switch $browser and $_SERVER['HTTP_USER_AGENT']. Also, I think that require() will automatically include the 'css/navoverride.css', whether the person is browsing with Internet Explorer or not. I think this should work correctly.

[PHP]<style type="text/css">
<?php

$browser = $_SERVER['HTTP_USER_AGENT'];
if (stristr ($browser,"msie")) {
include('css/navoverride.css'); // the CSS required to kill the IE-offending div is here
}

?>
</style>[/PHP]
Yup. I got it working. After realizing I accidentally switched the variable arguement. Require worked just fine, though. I am not sure what the difference between the two is, I just always use require.

That all said, am still just a PHP newb.

Sadly, being a technology pundit is truly never having to say you’re sorry. You can be wrong for years and never lose your job.—The Macalope
  quote
Posting Rules Navigation
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Post Reply

Forum Jump
Thread Tools

« Previous Thread | Next Thread »

All times are GMT -5. The time now is 12:04.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright ©2004 - 2019, AppleNova