Bluehost.com Web Hosting $6.95

calling a php script using img src ="random.php"

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... &...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #11 (permalink)  
Old 04-20-2005
bhennon@gmail.com
 
Posts: n/a
Default Re: calling a php script using img src ="random.php"


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>&nbsp;</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

Reply With Quote
  #12 (permalink)  
Old 04-20-2005
BKDotCom
 
Posts: n/a
Default Re: calling a php script using img src ="random.php"

for a "processing" image use the lowsrc attribute

<img lowsrc="path/processing.gif" src="/frag/status.php?addr=addr.net"
width="37" height="20">

Reply With Quote
  #13 (permalink)  
Old 04-20-2005
BKDotCom
 
Posts: n/a
Default Re: calling a php script using img src ="random.php"

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.

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 02:55 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0