Executing php code within an iframe

G

Guest

I am trying to execute a php script within an iframe, if I open up the html
page on a standalone browser the php code executes, but running it from my
server nothing happens, I basically have an html page
<html>
....
<iframe>
link to php script
</iframe>
</html>

Is there something blatant I am doing wrong?
 
T

Tyrone Slothrop

I am trying to execute a php script within an iframe, if I open up the html
page on a standalone browser the php code executes, but running it from my
server nothing happens, I basically have an html page
<html>
...
<iframe>
link to php script
</iframe>
</html>

Is there something blatant I am doing wrong?

Without more info, anything that could be offered is a guess.

Is the script supposed to trigger when the parent opens? If not, what
triggers it? Are all of your paths set properly?
 
?

=?iso-8859-1?Q?Kim_Andr=E9_Aker=F8?=

Nospam said:
I am trying to execute a php script within an iframe, if I open up
the html page on a standalone browser the php code executes, but
running it from my server nothing happens, I basically have an html
page <html>
...
<iframe>
link to php script
</iframe>
</html>

Is there something blatant I am doing wrong?

You do mean you're calling it like this (when using iframe), right?

<iframe src="path/to/script.php"></iframe>
 
H

Harlan Messinger

Nospam said:
I am trying to execute a php script within an iframe, if I open up the html
page on a standalone browser the php code executes, but running it from my
server nothing happens, I basically have an html page
<html>
...
<iframe>
link to php script
</iframe>
</html>

Is there something blatant I am doing wrong?

Your questions are hard to answer because you keep explaining the
situation and what you're attempting to do in vague or meaningless terms
instead of with relevant information. PHP scripts don't execute with an
IFRAME, they execute on a server. I don't know what you mean by opening
"the" HTML page in a standalone browser (as opposed to what other kind
of browser?) or why you are making a distinction between that and
running it on a server--PHP *always* runs the server.

Meanwhile you're not bothering to show the code. So how do we know
what's causing the problem? We certainly can't tell from what you've
told us. If you think we can, it reflects some misconceptions about the
respective roles of the browser and the server and misunderstandings
about which has what information and about what runs where.

When a server receives a request, it has no idea whatsoever what was
clicked or activated to generate that kind of request--a hyperlink, a
button, a Javascript call initiated by a mouseover or timer, an address
typed into the browser's address field. If it doesn't know that a
hyperlink was clicked, it certainly doesn't know that the hyperlink is
inside an IFRAME. The server just processes the request, generates a
response, and sends it back to the browser.

The browser is responsible for determining what to do with the response
once it arrives. The browser has no idea how the response was
generated--by HTML or binary code being read straight out of a file or
by a program, be it ASP, PHP, JSP, Perl, etc., generating it dynamically.
 
G

Guest

Harlan Messinger said:
Your questions are hard to answer because you keep explaining the
situation and what you're attempting to do in vague or meaningless terms
instead of with relevant information. PHP scripts don't execute with an
IFRAME, they execute on a server. I don't know what you mean by opening
"the" HTML page in a standalone browser (as opposed to what other kind
of browser?) or why you are making a distinction between that and
running it on a server--PHP *always* runs the server.

Meanwhile you're not bothering to show the code. So how do we know
what's causing the problem? We certainly can't tell from what you've
told us. If you think we can, it reflects some misconceptions about the
respective roles of the browser and the server and misunderstandings
about which has what information and about what runs where.

When a server receives a request, it has no idea whatsoever what was
clicked or activated to generate that kind of request--a hyperlink, a
button, a Javascript call initiated by a mouseover or timer, an address
typed into the browser's address field. If it doesn't know that a
hyperlink was clicked, it certainly doesn't know that the hyperlink is
inside an IFRAME. The server just processes the request, generates a
response, and sends it back to the browser.

The browser is responsible for determining what to do with the response
once it arrives. The browser has no idea how the response was
generated--by HTML or binary code being read straight out of a file or
by a program, be it ASP, PHP, JSP, Perl, etc., generating it dynamically.


Basically I have a php script that shows an image:

<?php

echo "<img src='http://www.example.com/image1.jpg' width='60' height='60'>";

?>

I also have an iframe that has this:

<iframe src="http://www.example.com/script1.php"></iframe>

However the image is not displayed at all (i.e the script is not run, but it
runs if I run it offline)

I am wondering what needs to be done for the script to run online
 
J

Jonathan N. Little

Nospam said:
Basically I have a php script that shows an image:

<?php

echo "<img src='http://www.example.com/image1.jpg' width='60' height='60'>";

?>

I also have an iframe that has this:

<iframe src="http://www.example.com/script1.php"></iframe>

However the image is not displayed at all (i.e the script is not run, but it
runs if I run it offline)

I am wondering what needs to be done for the script to run online

Why the IFRAME at all??? Just

<?php include('script1.php'); ?>

and be done with it!
 
G

Guest

Jonathan N. Little said:
Why the IFRAME at all??? Just

<?php include('script1.php'); ?>

and be done with it!

I would like anyone viewing the page to be redirected to the php script
within the iframe (or directed still somehow on the same page, was told an
iframe could do this)
 
H

Harlan Messinger

Nospam said:
I would like anyone viewing the page to be redirected to the php script
within the iframe (or directed still somehow on the same page, was told an
iframe could do this)

I don't know what you mean by "directed" and "redirected". From your
previous message I assumed you meant that script1.php was the file that
contained the code you showed us that generates the IMG tag. So the
response from script1.php should be displayed inside the IFRAME. No
redirection is involved in that.

Besides that, a single IMG tag is not a valid HTML document. Technically
you can get along with just a DOCTYPE declaration and a TITLE tag in
addition to the IMG tag.

I agree with Jonathan: I still can't figure out what you're really
trying to accomplish or why you need an IFRAME to do it.
 
G

Guest

Harlan Messinger said:
I don't know what you mean by "directed" and "redirected". From your
previous message I assumed you meant that script1.php was the file that
contained the code you showed us that generates the IMG tag.
Yes

So the
response from script1.php should be displayed inside the IFRAME. No
redirection is involved in that.

I should have mentioned that the iframe should have two images, one the
initial image, and the second the redirected image contained in script1.php

i.e

initially

<html>
<title> Tile</title>
....<iframe scr= "http://www.example.com/1.html "></iframe>
</html>

should redirect to:

<html>
<title> Tile</title>
....<iframe scr= "http://www.example.com/script1.php"> </iframe>
</html>
 
S

Steve

|
| | > Nospam wrote:
| > > | > >> Nospam wrote:
| > >>
| > >>> Basically I have a php script that shows an image:
| > >>>
| > >>> <?php
| > >>>
| > >>> echo "<img src='http://www.example.com/image1.jpg' width='60'
| > > height='60'>";
| > >>> ?>
| > >>>
| > >>> I also have an iframe that has this:
| > >>>
| > >>> <iframe src="http://www.example.com/script1.php"></iframe>
| > >>>
| > >>> However the image is not displayed at all (i.e the script is not
run,
| > > but it
| > >>> runs if I run it offline)
| > >>>
| > >>> I am wondering what needs to be done for the script to run online
| > >> Why the IFRAME at all??? Just
| > >>
| > >> <?php include('script1.php'); ?>
| > >>
| > >> and be done with it!
| > >
| > > I would like anyone viewing the page to be redirected to the php
script
| > > within the iframe (or directed still somehow on the same page, was
told
| an
| > > iframe could do this)
| >
| > I don't know what you mean by "directed" and "redirected". From your
| > previous message I assumed you meant that script1.php was the file that
| > contained the code you showed us that generates the IMG tag.
|
| Yes
|
| > So the
| > response from script1.php should be displayed inside the IFRAME. No
| > redirection is involved in that.
|
| I should have mentioned that the iframe should have two images, one the
| initial image, and the second the redirected image contained in
script1.php
|
| i.e
|
| initially
|
| <html>
| <title> Tile</title>
| ...<iframe scr= "http://www.example.com/1.html "></iframe>
| </html>
|
| should redirect to:
|
| <html>
| <title> Tile</title>
| ...<iframe scr= "http://www.example.com/script1.php"> </iframe>
| </html>

omfg! enough already! there is NO redirecting going on and, you should be
mentioning a LOT more than that...like why you need and iframe in the first
place!
 
B

Bergamot

Nospam said:
I should have mentioned that the iframe should have two images, one the
initial image, and the second the redirected image contained in script1.php

You seem to be misusing the word "redirected", but nobody knows for
sure. Post a URL.
 
J

Jonathan N. Little

Nospam said:
I should have mentioned that the iframe should have two images, one the
initial image, and the second the redirected image contained in script1.php

i.e

initially

<html>
<title> Tile</title>
...<iframe scr= "http://www.example.com/1.html "></iframe>
</html>

should redirect to:

<html>
<title> Tile</title>
...<iframe scr= "http://www.example.com/script1.php"> </iframe>
</html>

Sounds more like some sort of image swap, you do not need an IFRAME for
this, maybe some JavaScript. Listen to the mantra: "Post a URL, post a
URL, post a URL..."
 
G

Guest

Jonathan N. Little said:
Sounds more like some sort of image swap, you do not need an IFRAME for
this, maybe some JavaScript. Listen to the mantra: "Post a URL, post a
URL, post a URL..."

This is what I am trying to accomplish:



<META http-equiv="Refresh" content="5
url=http://www.onzemaninteheran.com/uploaded_images/microphone-755244.jpg"
Target=_blank">"
<html>
<body>
<Iframe src="http://www.bizpodcasting.com/uploads/Microphone 4.gif"
width="60" height="60"></Iframe>
</body>
</html>

Initially the image
http://www.onzemaninteheran.com/uploaded_images/microphone-755244.jpg should
be in the iframe, and is replaced by
http://www.bizpodcasting.com/uploads/Microphone 4.gif (this is the image
contained in the script1.php file)
 
S

Steve

| <META http-equiv="Refresh" content="5
| url=http://www.onzemaninteheran.com/uploaded_images/microphone-755244.jpg"
| Target=_blank">"
| <html>
| <body>
| <Iframe src="http://www.bizpodcasting.com/uploads/Microphone 4.gif"
| width="60" height="60"></Iframe>
| </body>
| </html>


<html>
<script language="javascript">
var newSource =
'http://www.bizpodcasting.com/uploads/Microphone 4.gif';
var initialDelay = 0;
var refreshDelay = 0;
function changeImage()
{
if (initialDelay)
{
clearTimeout(initialDelay);
initialDelay = 0;
if (!refreshDelay){ refreshDelay = setInterval('changeImage()', 5 *
1000); }
}
if (!document.getElementById('imageToSwap')){ return; }
document.getElementById('imageToSwap').src = newSource;
}
function initialize()
{
initialDelay = setTimeout('changeImage()', 5 * 1000);
}
function quit()
{
if (initialDelay)
{
clearTimeout(initialDelay);
initialDelay = 0;
}
if (refreshDelay)
{
clearInterval(refreshDelay);
refreshDelay= 0;
}
}
</script>
<body onload="initialize();" onunload="quit();">
<img id="imageToSwap"
src="http://www.onzemaninteheran.com/uploaded_images/microphone-755244.jpg"
</body>
</html>
 
H

Harlan Messinger

Nospam said:
This is what I am trying to accomplish:

<META http-equiv="Refresh" content="5
url=http://www.onzemaninteheran.com/uploaded_images/microphone-755244.jpg"
Target=_blank">"
<html>
<body>
<Iframe src="http://www.bizpodcasting.com/uploads/Microphone 4.gif"
width="60" height="60"></Iframe>
</body>
</html>

This isn't a what, this is a how.
Initially the image
http://www.onzemaninteheran.com/uploaded_images/microphone-755244.jpg should
be in the iframe, and is replaced by
http://www.bizpodcasting.com/uploads/Microphone 4.gif (this is the image
contained in the script1.php file)

When? Under what circumstances? Besides, you still haven't given any
explanation of what you are trying to accomplish that would point to an
IFRAME as being part of the solution. And now you're thrown in a refresh
META tag. I'm sorry, but it's too much trouble to get you to explain
this. You only reveal what you're want to accomplish a piece at a time,
and you keep obfuscating the situation by throwing in code that you seem
to think is part of the solution without indicating why you think so and
without it being apparent that it belongs there.
 
S

Steve

| When? Under what circumstances? Besides, you still haven't given any
| explanation of what you are trying to accomplish that would point to an
| IFRAME as being part of the solution. And now you're thrown in a refresh
| META tag. I'm sorry, but it's too much trouble to get you to explain
| this. You only reveal what you're want to accomplish a piece at a time,
| and you keep obfuscating the situation by throwing in code that you seem
| to think is part of the solution without indicating why you think so and
| without it being apparent that it belongs there.

exactly, however if you look at nospam's posts over the past year here, you
see that this is his mo. further, that he shouldn't be programming. again,
that he should invest in RTFM and google if he plans to continue
noobgramming. and finally, that he's not too bright. although, if he's
getting paid for his work we should thank him. they are those programmers of
his caliber that allow us higher incomes through a client's awareness of
quality differences. thank you nospam! you make it possible for my clients
not to gasp for air or bust out laughing when i ask $150 usd per hour to
make simple enhancements to their existing functional base. ;^)
 
B

Bergamot

Nospam said:
This is what I am trying to accomplish:

Looks more like you are trying to fix the wrong problem. You've decided
on a solution before you've even figured out what the real goal is.

Don't post code, post a URL.
 
M

Markus Ernst

Nospam said:
<META http-equiv="Refresh" content="5
url=http://www.onzemaninteheran.com/uploaded_images/microphone-755244.jpg"
Target=_blank">"
<html>
<body>
<Iframe src="http://www.bizpodcasting.com/uploads/Microphone 4.gif"
width="60" height="60"></Iframe>
</body>
</html>

Ouf - you have a quite serious HTML problem, not a PHP one. Use
http://validator.w3.org/ to find out how to fix your HTML source. Once
it validates, post the URL to the page if the problem still exists. Just
a hint: Meta refresh does refresh the page itself, and not the contents
of an iframe. Anyway I agree with other posters that neither an iframe
nor a meta refresh tag are useful for image swapping.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top