Jump to content

[SOLVED] Making this php file output as a jpg


rondog

Recommended Posts

I am trying to make it so when you go to this php file it generates it and displays the image. I have this right now and according to my browser its a jpg, but I just see a string of text.

 

<?php
header("Content-type: image/jpeg");
include "connect.php";

$today = date("Y-m-d");
$today = strtotime($today);

$query = mysql_query("SELECT event_image FROM de_featuredevent WHERE '$today' BETWEEN start_date AND end_date") or die(mysql_error());
$row = mysql_fetch_array($query);
$img = $row['event_image'];

imagecreatefromjpeg("featuredimages/".$img);
?>

 

http://drewestate.com/new/2008/loadfeaturedevent.php

Yea thats all of the code for that php file. The extension of the image is jpg. The PHP should be able to output a jpeg.

 

$img = $row['event_image']; is going to be equal to event1.jpg

 

so the image path is now:

 

"featuredimages/event1.jpg"

 

and I am using imagecreatefromjpeg to do that. Is that the wrong function? I've tried imagejpeg as well and same thing.

 

 

oh duh haha..i got it

<?php
include "connect.php";

$today = date("Y-m-d");
$today = strtotime($today);

$query = mysql_query("SELECT event_image FROM de_featuredevent WHERE '$today' BETWEEN start_date AND end_date") or die(mysql_error());
$row = mysql_fetch_array($query);
$src = "featuredeventimages/".$row['event_image'];

header("Content-type: image/jpeg");
$img = imagecreatefromjpeg($src);
$img = imagejpeg($img);
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.