I am a php newbie, but I have successfully created two different kinds of scripts so far: one that generates links with info pulled from a database, and one that creates an image "on the fly" using info pulled from a database.
My problem is, I am now trying to include the two operations in one script, and whenever I do, the image portion of the script just creates a lot of gobbledy-gook text.
I thought at first that it was a header problem, since I was originally getting header error messages, but the header error messages, at least, stopped after I added the following html code to the very top of my php script:
<meta http-equiv="content-type" content="multipart/mixed; charset=utf-8" /></meta>
Nevertheless, my browser still returns garbage when it reaches the part where it should be generating an "on the fly" image for me.
Below you will find what I think are the relevant portions of the script. Thanks in advance for any ideas on how to get it to work!
Brian
Alexandria, Virginia
Code: Select all
<html>
<head>
<meta http-equiv="content-type" content="multipart/mixed; charset=utf-8" /></meta>
</head>
<?php
$result=mysql_query ("SELECT * FROM `Articles`
ORDER BY `Title`");
while ($row = mysql_fetch_assoc($result)) {
echo $row['Title'];
//And now the image part that I can get to work on its own, but not here:
$Title = $row['Title'];
$im = imagecreatefromjpeg("myimage.jpg");
$orange = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
imagestring($im, 5, 90, 115, $Title, $orange);
$x1= "77";
$y1="43";
$size="10";
$x2 = $x1+$size;
$y2 = $y1+$size;
imagefilledrectangle ( $im, $x1, $y1, $x2, $y2, $black );
imagejpeg($im);
imagedestroy($im);
}
?>