Page 1 of 1

curl IMAGE problem

Posted: Thu Nov 03, 2005 6:26 am
by pedroz
Dear coders,

I would be very glad if you could help me with this problem.
I cannot use cookies, sessions or html <img command and I would like to display an image while running index.php and keep executing the script but it stops when I include test.php. Any ideas to solve this ?

Thanks


Conditions:
// NO COOKIES, NO SESSIONS
// NO <img src=’teste.php?id=fox1’…


> FILE 1 index.php

Code: Select all

$id='fox1';

include ("test.php");
image_display($id);

// PROBLEM HERE! 
// code stops in the line above. doesn’t execute the lines below
echo "output: ".$id;
echo “THE END”;
> FILE 2 test.php

Code: Select all

function image_display($id){

$ch = curl_init("http://www.google.es/images/firefox/".$id.".gif");
if (!$ch) { die( "Cannot allocate a new PHP-CURL handle" ); }

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);

$data = curl_exec($ch);
curl_close($ch);

header("Content-type: image/jpeg");
print ($data);

Posted: Thu Nov 03, 2005 7:40 am
by feyd
Choose one, either echo the text or the image. Images cannot be sent in the same stream as textual data.