Hi all,
I am Running PHP4.3.1, MySql on Apache2 using XP pro.
I have been having great success with PHP ..untill I began the chapter in my book on generating images and manipulation. As soon as i started with the functions ImageCreateFrom???? () things have gone wrong. None of my PHP scripts seem to run . I dont get error messages just a blank page or a broken link in my html page. Looking back over my php.ini ect i seem to be correct but any suggestions are welcome. Here is the suspect code:
resize_image.php
<?php
$image = $HTTP_GET_VARS['image'];
if (!$max_width)
$max_width = 80;
if (!$max_height)
$max_height = 60;
$size = GetImageSize($image);
$width = $size[0];
$height = $size[1];
$x_ratio = $max_width / $width;
$y_ratio = $max_height / $height;
if ( ($width <= $max_width) && ($height <= $max_height) ) {
$tn_width = $width;
$tn_height = $height;
}
else if (($x_ratio $height) < $max_height) {
$tn_height = ceil($x_ratio $height);
$tn_width = $max_width;
}
else {
$tn_width = ceil($y_ratio * $width);
$tn_height = $max_height;
}
$src = ImageCreateFromJpeg($image);
$dst = ImageCreate($tn_width,$tn_height);
ImageCopyResized($dst, $src, 0, 0, 0, 0,
$tn_width,$tn_height,$width,$height);
header('Content-type:image/jpeg');
ImageJpeg($dst, null, -1);
ImageDestroy($src);
ImageDestroy($dst);
?>
and here is the php that calls the above:
<?php
include('include_fns.php');
include('header.php');
$conn = db_connect();
$pages_sql = 'select * from pages order by code';
$pages_result = mysql_query($pages_sql, $conn);
while ($pages = mysql_fetch_array($pages_result)) {
$story_sql = "select * from stories
where page = '".$pages['code']."'
and published is not null
order by published desc";
$story_result = mysql_query($story_sql, $conn);
if (mysql_num_rows($story_result)) {
$story = mysql_fetch_array($story_result);
print '<table border="0" width="400">';
print '<tr>';
print '<td rowspan="2" width="100">';
if ($story[picture])
print "<img src=\"resize_image.php?image=$story[picture]\"/>";
print '</td>';
print '<td>';
print '<h3>'.$pages['description'].'</h3>';
print $story['headline'];
print '</td>';
print '</tr>';
print '<tr><td align="right">';
print '<a href="page.php?page='.$pages['code'].'">';
print '<font size="1">Read more '.$pages['code'].' ...</font>';
print '</a>';
print '</table>';
}
}
include('footer.php');
?>
Thanks again to all those who have helped or nudged me in the right direction. Barry.