This is a discussion on calling a php script using img src ="random.php" within the PHP Language forums, part of the PHP Programming Forums category; Tex John wrote: > "Dahak" <Dahak_II@thefifthimperium.com> wrote in message > news:pf8051td36s9ia5eqbl1c1bsgsj81iev74@4ax.com... &...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Tex John wrote: > "Dahak" <Dahak_II@thefifthimperium.com> wrote in message > news:pf8051td36s9ia5eqbl1c1bsgsj81iev74@4ax.com... > > On Thu, 17 Mar 2005 00:02:16 +0100, an orbiting mind-control laser > > made "Alvaro G. Vicario" <kAlvaroNOSPAMTHANKS@terra.es> write: > > > > >*** bhennon@gmail.com escribió/wrote (16 Mar 2005 13:33:26 -0800): > > >> http://www.2006ymcanationals.com/random.php > > >> > > >> IT WORKS IF I go directly to the above link. > > >> > > >> I am trying to call that in another page so that i get a random image > > >> the page is http://2006ymcanationals.com/index.php using <img > > >> src="random.php"> > > > > > >Your script does not return an image. It returns an HTML page that links > to > > >an image. You cannot link to an HTML page with the <img> tag. Maybe > you're > > >thinking of <iframe>? > > > > > >You could either choose a random filename: > > > > > ><img src="<?=get_random_img_name()?>"> > > > > > >Or make your script return an actual image: > > > > > > Here's a working example that might help. This checks to see if a website is > up and if it is, it displays a smiley gif and if not, a not so smiley gif in > a table of smileys. Now the page doesn't wait for ALL the smileys to not > time out before displaying; rather it displays the whole table immediately > and these pop up as they finish running. Now if it would only display a > "processing" gif while we waited :>) > > ==== An Actual Table Row ====== > > <tr> > <td>Logon.net</td> > <th><img src="/frag/status.php?addr=www.logon.net" width="37" > height="20"></th> > <th><img src="/frag/status.php?addr=mail.logon.net&port=25" width="37" > height="20"></th> > <th><img src="/frag/status.php?addr=mail.logon.net&port=110" width="37" > height="20"></th> > <th><img src="/frag/status.php?addr=mail.logon.net" width="37" > height="20"></th> > <th> </th> > </tr> > > ==== status.php has to be above Doc Root =============== > > <?php > //Web Server Status v 1.2, Copyright 2002 By Ryan Schwiebert, visit > http://www.schwebdesigns.com/ > //This script may be freely distributed providing all copyright headers are > kept intact. > > //Concept from: > //Abax Server Status v1.04, Copyright 2002 By Nathan Dickman, visit > http://www.NathanDickman.com/ > //Location of the live or dead server images > > // Updated by John Jarrett 2003 > > //Please change to your server specifications > $live = "/frag/images/live2.gif"; > $dead = "/frag/images/dead2.gif"; > > //The status checking script > //meddle at your own risk! > //check for port number, default is 80 > #list($addr,$port)= explode (':',"$link"); > if (empty($port)) { > $port = 80; > } > > //Test the server connection > > $churl = @fsockopen(server($addr), $port, $errno, $errstr, 20); > #$churl = @fsockopen($addr, $port, $errno, $errstr, 20); > if (!$churl){ > header("Location: $dead"); > } > else { > header("Location: $live"); > } > function server($addr){ > if(strstr($addr,"/")){$addr = substr($addr, 0, strpos($addr, > "/"));} > return $addr; > } > ?> > > ====== end of script ===== > > hth, > John I was never able to get this working. Some people say you cannot call a php script that outputs html from within an html page and others say that it works. Which is it? Looks like it works in Johns example. John, could you post the rest of the html from your example? Is the page named index.php or index.html? Is there an opening and closing php statement in the page somewhere? "<?php" and "?>" Thanks for your help. Brad |
|
|||
|
Nobody said that..
what was said that the image tag needs to have a SRC attribute (not href) and the SRC needs to be a url to a valid image document (whether generated on the fly via a script or whatever). your image tag just so happens to reference something that outputs html.. which not-suprisingly gives a broken image. |