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

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

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);
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.