Page 1 of 1

transparent iframes using php

Posted: Thu Jun 23, 2005 9:53 am
by irishelysia
hey..first off i know absolutely nothing about PHP...
I was trying to validate my site, and someone said that the way i was doing my iframes wasn't "valid." (I'm trying to fix probs with mozilla/ie compatibility and such)

So they instructed me to do them like this:

Code: Select all

<iframe src="http://www.irishelysia.net/greymatter/index.html" frameborder="0" height="345" width="460" name="frame" <?php if (ereg('MSIE', $_SERVER['HTTP_USER_AGENT'])) { echo 'allowtransparency="true"'; } ?>>
</iframe>
This works ok in mozilla, but not in IE. Also if you view the source code in mozilla somehow an extra ">" is added so the code appears like this:

Code: Select all

<iframe src="http://www.irishelysia.net/greymatter/index.html" frameborder="0" height="345" width="460" name="frame"><?php if (ereg('MSIE', $_SERVER['HTTP_USER_AGENT'])) { echo 'allowtransparency="true"'; } ?>>
</iframe>
(Note the extra ">" added after "name="iframe")
When I look at the source code in IE it appears the way I put it in...but doesnt work.

I'm wondering if my ignorance to PHP is causing a problem here or if theres an easy fix..or if i should remove the PHP alltogether.

The people who were helping me at another forum seemed to though the problem was with the extra "<" but no one knew how to fix it.

I hope i followed the "code posting rules" here, lol..i tried.
Thanks for your help very much

Elysia

Posted: Thu Jun 23, 2005 9:57 am
by pickle
PHP is never seen by the validating service, or even your browser for that matter. PHP doesn't have any affect on the validity of the page. What you need to look at is the result of what PHP echoes. Start by looking at the source code in from both browsers and see what it looks like.

Posted: Thu Jun 23, 2005 10:00 am
by irishelysia
yeah...thats what i mean...it shows the extra ">" in ie but not in mozilla.


Do you mean it shouldnt show the php in the source at all?

Posted: Thu Jun 23, 2005 10:11 am
by pickle
No, it shouldn't. PHP is a Hypertext Pre-Processor. It's a server-side language that is run by Apache. The output from your PHP scripts then get sent on to the browser. Any browser viewing a PHP page actually thinks its viewing an HTML page.

If PHP code is showing up in your final web page, then PHP might not be installed/configured properly. In some installations (maybe all), you need to name a file with a .php extension in order for PHP to be evaluated. If the file has a .html or some other extension, Apache doesn't even send it to the PHP processor.

Make a page called test.php with the following code in it:

Code: Select all

<?PHP

phpinfo();

?>
If that outputs something then PHP is installed and running. If this is the case, try renaming the page that generates the code you posted, to have a .php extension and see if that gets interpreted properly.

Incidently. The fact that PHP isn't being interpreted is also probably why you see an extra '>'

Posted: Thu Jun 23, 2005 10:23 am
by irishelysia
Ok, i think i see what you mean.

I tried the test page and i got a nice little table filled with things...

I renamed my index.html to index.php. Now it works in IE and mozilla which really excites me because ive been trying to figure this out forever. Clearly the problem was i didnt understand PHP properly.

I deleted my index.html file...so now its just going to index.php automaticaly right?
This shouldnt change anything else on my site, should it? (considering thats the only php anywhere on the site..)
Thanks so much for your help!

Posted: Thu Jun 23, 2005 11:03 am
by pickle
Well, Apache needs to be configured properly so that it can check for index.php as the main page. I've never seen an instance though, where PHP was installed, and index.php wasn't set up as a potential main page. It should work fine.

Posted: Thu Jun 23, 2005 11:19 am
by irishelysia
i deleted index.html and it works perfectly.

Well, at least that problem is fixed. Now on to tackle my millions of other (non php related) compatibility issues.

Thanks very much, I appreciate your patience with someone who is very ignorant when it comes to php!
much appreciated,
elysia

Posted: Thu Jun 23, 2005 11:25 am
by pickle
Everyone here was ignorant of PHP at one time or another. We're glad to help.