Ok I've gotten pretty far but I am now very stuck, I've tried my hardest to figure it out.
It says cannot modify header information or already set. What I'm trying to do is pull random quotes from my database, I can display random quotes by TEXT with echo but cant seem to get them to work with my image code below:
PHP Code:<?php
// Set the content-type
header("Content-type: image/gif");
$fontsize = 15;
if(@$_GET['fontsize']) {
$fontsize = $_GET['fontsize'];
}
$font = 'times.ttf';
$domain = GetHostByName($REMOTE_ADDR);
$text = @$_GET['text'];// . "" . $domain;
// Create the image
$size = imagettfbbox($fontsize, 0, $font, $text);
$width = $size[2] + $size[0] + 8;
$height = abs($size[1]) + abs($size[7]);
$im = imagecreate($width, $height);
$colourBlack = imagecolorallocate($im, 255, 255, 255);
imagecolortransparent($im, $colourBlack);
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
// Add the text
imagefttext($im, $fontsize, 0, 0, abs($size[5]), $black, $font, $text);
// Using imagepng() results in clearer text compared with
imagegif($im);
imagedestroy($im);
?>
Both codes work how I want them to when they are separate. What's going on here?!
The code freaks out when I add this:
PHP Code:<?php
header("Content-type: image/gif");
mysql_connect("SERVER", "USERNAME", "PASSWORD") or die(mysql_error());
mysql_select_db("Servic4_msr") or die(mysql_error());
?>
<?php
$query = "SELECT * FROM quotes ORDER BY RAND()LIMIT 1";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
$line = $row['lines'];
}
?>




Reply With Quote