Page 1 of 2
Quick PHP problem...
Posted: Mon Oct 30, 2006 6:13 pm
by Deathblade
Alright, so ive got a piece of HTML on site #1 that looks something like this:
Code: Select all
<img src='www.mysite.com/display.php?user=example'></img>
and i want it to load the image off of site #2 (
http://www.mysite.com/display.php)
in display.php
there is this:
Code: Select all
<img src='www.mysitecom/images/1.gif'></img>
<img src='www.mysitecom/images/2.gif'></img>
<img src='www.mysitecom/images/3.gif'></img>
<img src='www.mysitecom/images/4.gif'></img>
four images. This works when display.php is a text file, as in all of the images load. However, when the four images are generated from display.php, it just produces a broken image. How can i get PHP to dynamically generate the HTML of four images that an external site can read as HTML?
I'm sorry if that was a bit confusing but anything helps! I'm really stuck here and just need a little push.
Thanks a lot
~Deathblade
And by the way i did get the <img src> to load up 4 images from a single file that had the source of all 4 of them in it. Surprised me, but it worked.
Posted: Mon Oct 30, 2006 8:07 pm
by feyd
If your remote script is generating the <img> tags, file_get_contents() or a sibling can pull that textual data on your local server.
Posted: Mon Oct 30, 2006 8:56 pm
by Deathblade
i know. see the thing is, im trying to get it so somebody can just paste that one line of HTML on their site and have it load up the images. it cant use any PHP or anything, it has to just be that one line of HTML. is that even possible?
Posted: Mon Oct 30, 2006 9:13 pm
by feyd
Not even remotely. It would require Javascript to generate more than a single image.
Posted: Mon Oct 30, 2006 9:30 pm
by Deathblade
damn. is there any other way of having the user paste html code that could dynamically load from PHP?
Posted: Mon Oct 30, 2006 9:31 pm
by feyd
If they placed each image (and the url's were unique so the images weren't cached so readily.)
Posted: Mon Oct 30, 2006 9:59 pm
by Deathblade
okay...
so i made a PHP file that echos the HTML for an image source.
i got an HTML file and did an <img src='the php file i just made'></img>
but it just makes a broken image, and when i right click it says location: myphpfile
what am i doing wrong?
Posted: Mon Oct 30, 2006 10:09 pm
by feyd
It should return the binary image data that is to be displayed.
Posted: Mon Oct 30, 2006 10:14 pm
by Deathblade
all it has is a broken image whose source is my php file. how would i find the binary?
Posted: Mon Oct 30, 2006 10:30 pm
by feyd
Since it's returning an image tag, it should use the URL that it has.
Posted: Tue Oct 31, 2006 10:45 pm
by Deathblade
feyd wrote:Since it's returning an image tag, it should use the URL that it has.
well...that explains it all? anybody other than feyd want to help me out?
Posted: Tue Oct 31, 2006 11:04 pm
by John Cartwright
you'll find if you do a bit of searching around for the things he's mentioned you'll easily find your solution..
anyways, hint
readfile()
Posted: Tue Oct 31, 2006 11:09 pm
by Deathblade
it has to be able to run off of a server that doesnt support PHP. only reads it from HTML like a text file to get the source for the images. i didnt explain this very well did i?
i made a great example in my other thread before it got locked...
Posted: Tue Oct 31, 2006 11:39 pm
by John Cartwright
Deathblade wrote:it has to be able to run off of a server that doesnt support PHP. only reads it from HTML like a text file to get the source for the images. i didnt explain this very well did i?
i made a great example in my other thread before it got locked...
So you have Server A (with PHP) pulling images from Server B (no PHP)?
If that's the case then that doesn't change anything. As Feyd mentioned, use
file_get_contents() to pull the image from Server B, and then read the binary data with
readfile()
Did I understand correctly?
Posted: Wed Nov 01, 2006 12:26 am
by aaronhall
Deathblade wrote:it has to be able to run off of a server that doesnt support PHP. only reads it from HTML like a text file to get the source for the images. i didnt explain this very well did i?
i made a great example in my other thread before it got locked...
The other thread was locked because those links could just as easily have been posted here.
Can you give us the context of the problem you are trying to solve? You may get some better solutions that way.