<html>
<body>
<h1>It sorta works!</h1>
<img src="<?php tach.php?p=30 ?>" width=200 height=200 alt="tach">
</body>
</html>
The trouble is get only the image placeholder and the alt text but
no image.
tach.php has a content header and looks like this (some code dropped to
just show relevant stuff, I already am sure its creating an image)
<?php
header("Content-type: image/png");
$img=imagecreate(200,200);
[snip other stuff that makes the image]
imagepng($img);
imagedestroy($img);
?>
I'm using lighttpd and testing this on my local machine, i have phpsysinfo
installed and lighttpd handles that ok, so I think php itself is fine
also, "php-fastcgi -f tach.php" doesnt show any errors
I'm doing all this in linux.
My goal is to run a script that uploads weather info to my website every 5
minutes or so and the page would dynamically create the images for the
various instruments each time its loaded (or reloaded).
Thanks
Cat22
Lose the script tags <?php and ?>, thus:
<img src="tach.php?p=30" width=200 height=200 alt="tach">
It's unclear why you believed they were necessary, since what's inside them is
*not* PHP code. It's just a URL.
Although I have often used php to generate buttons and such, I usually
just download them to my computer as png images. Some are buttons
without text which are then easy to upload to my site to add text with
php as needed. If I understand you correctly, you need to generate and
display a new image often even while the same page is being displayed.
This is a bit different from what I have needed so far, so I suggest
that you post in comp.lang.php if you do not get an answer here that
helps within the next day or so.
--
Pete Ives
Remove All_stRESS before sending me an email
> I have a php script that generates an image to stdout, i can redirect the
> script to a file and load the file and thats ok, but what iwant to do is
> something like this
><html>
><body>
><h1>It sorta works!</h1>
><img src="<?php tach.php?p=30 ?>" width=200 height=200 alt="tach">
></body>
></html>
> The trouble is get only the image placeholder and the alt text but
> no image.
> tach.php has a content header and looks like this (some code dropped to
> just show relevant stuff, I already am sure its creating an image)
The src attribute of IMG is not for the image itself, but for a link to the
image. This is just basic HTML. The image does not go in the HTML (yes,
there now are ways to get various kinds of binary data in HTML documents,
but that is not IMG with src.
Instead of <img src="<?php tach.php?p=30 ?>", <img src="tach.php?p=30"
should put you on the right track. Otherwise, whatever tach.php puts out
is what the browser will try to request. Obviously there is no such file.
A similar thing will happen if you try to include a static image binary
between the quotes of src. If it won't work with a static image, it sure
won't work with an image generated on the fly.
><?php
> header("Content-type: image/png");
> $img=imagecreate(200,200);
> [snip other stuff that makes the image]
> imagepng($img);
> imagedestroy($img);
> ?>
> I'm using lighttpd and testing this on my local machine, i have phpsysinfo
> installed and lighttpd handles that ok, so I think php itself is fine
> also, "php-fastcgi -f tach.php" doesnt show any errors
> I'm doing all this in linux.
> My goal is to run a script that uploads weather info to my website every 5
> minutes or so and the page would dynamically create the images for the
> various instruments each time its loaded (or reloaded).
How would you handle it if you did not want a previously cached static image
reloaded? You see that is a different problem than generating an image on
the fly. Be sure you are not confusing the two problems.
--
Lars Eighner <http://larseighner.com/> Warbama's Afghaninam day: 32
780.7 hours since Warbama declared Viet Nam II.
Warbama: An LBJ for the Twenty-First century. No hope. No change.
> tach.php has a content header and looks like this (some code dropped to
> just show relevant stuff, I already am sure its creating an image)
>
> <?php
> header("Content-type: image/png");
> $img=imagecreate(200,200);
> [snip other stuff that makes the image]
> imagepng($img);
> imagedestroy($img);
> ?>
unfortunatly I don't know too much about it.
on linux webspaces it may be possible to use imagemagick - but on
windows servers not.
Well, this answer might only touch your backend problem - and not your
php issue.
*What* "php issue" are you talking about? He doesn't have a PHP issue. The
image won't display because his HTML is incorrect.
tach.php outputs the binary data bytes of the png image, not a filename, i
guess that isnt going to work?
> Doug Miller wrote:
tach.php is the url (aka filename); when the browser requests it, the
browser will get the image.
> i guess that isnt going to work?
It should work without the <?php tags. The server has to know to handle
tach.php as php, which it should if you are using php at all.
--
Lars Eighner <http://larseighner.com/> Warbama's Afghaninam day: 32
787.8 hours since Warbama declared Viet Nam II.
Did you try it????