simple_man_11 Posted May 30, 2007 Share Posted May 30, 2007 when using the below code I get the following error: The image “SecondType.php3” cannot be displayed, because it contains errors. <? include('config.php'); $query="SELECT * FROM Images where userID = '$userID' "; $result=mysql_query($query); while ($array= mysql_fetch_assoc($result)) { Header( "Content-type: image/gif"); echo "$user $array[image]"; } if (!$result) { echo "Did not retreive anything from the database"; } ?> I realize the problem is the line: echo "$user $array[image]"; where if I take out $user then it will display the image just fine. I need it to display an image and some text. I have a feeling that I need to use a different Header() function but am having no luck finding anything for mixed. Maybe this can not be done??? -------------------------------------------------------- if I do it like the following code then I get another error: user: chad Warning: Cannot modify header information - headers already sent by (output started at SecondType.php3:2) in SecondType.php3 on line 12 ÿØÿà�JFIF�,,��ÿí LPhotoshop 3.0�8BIMí Resolution����,����,����8BIM FX Global Lighting Angle�������x8BIMFX Global Altitude�������8BIMóPrint Flags��� ���������8BIM Copyright Flag������8BIM'Japanese .... (more gerberish).... <? echo "$user"; include('config.php'); $query="SELECT * FROM Images where userID = '$userID' "; $result=mysql_query($query); while ($array= mysql_fetch_assoc($result)) { Header( "Content-type: image/gif"); echo "$array[image]"; } if (!$result) { echo "Did not retreive anything from the database"; } ?> Link to comment https://forums.phpfreaks.com/topic/53654-php-header/ Share on other sites More sharing options...
per1os Posted May 30, 2007 Share Posted May 30, 2007 The header tells the browser what to expect, if you want to output text on the image look into the www.php.net/imagecreate functions to do that type of setup. But you cannot display text on a page that is suppose to be only an image. Link to comment https://forums.phpfreaks.com/topic/53654-php-header/#findComment-265216 Share on other sites More sharing options...
Caesar Posted May 30, 2007 Share Posted May 30, 2007 If you want to display image/text on the same page, you can't simply just plugin the variable in your php containing the text. Look here -> GD Library Link to comment https://forums.phpfreaks.com/topic/53654-php-header/#findComment-265218 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.