Originally posted by LordShryku
No, register_globals off, it should work either way. You may be overwritting it somewhere? Hard to say without the code.
<?php
$host ="localhost";
$user = linuxuser";
$pass ="qwerty";
dbConnect($host, $user, $pass);
$sql_images = mysql_query("SELECT image_small from ALBUM.album");
$mogrify ="/usr/bin/mogrify";
?>
<table align="center" border=0 cellpadding=2 cellspacing =5>
<?php
$count = 0;
while(list($image_small) = mysql_fetch_array($sql_images)){
if($count == 0)
echo "<tr><td>";
if($count != 0)
echo "<td>";
$count = $count + 1;
cropimage("images/$image_small", 150, 100, $mogrify);
//$thumb = "<A href=image_medium/$image_small border=1>". "<img src=images/"."$image_small"." border=1>"."</A>";
//$thumb = "<img src=images/"."$image_small"." border=1>";
$thumb = "<A href=test.php?image_name=$image_small>". "<img src=images/"."$image_small"." border=1>"."</A>";
list($width, $heigth) = getimagesize("images/$image_small");
echo $thumb. "<br>";
echo "<b><font size='2'> Image Size:</b> ".$width." x ";
echo $heigth. "</font>";
?> <td>
<?php
if($count / 4 == 1) {
$count =0;
echo "</tr>";
}
}?>
</table>
<?php
database_close($host, $user, $pass);
function database_close($host, $user, $pass) {
mysql_close(mysql_connect($host, $user, $pass));
}
function dbConnect($host,$user,$pass) {
$link = mysql_connect($host, $user, $pass) or die("Could not connect: ".mysql_error());
mysql_select_db("mysql");
}
function cropimage($picture,$fixedwidth,$fixedheight,$mogrify) {
// GET IMG
$img = imagecreatefromjpeg($picture);
$width= imagesx($img);
$height= imagesy($img);
// CROP WIDTH
if($width!=$fixedwidth){
$ratio =$fixedwidth/$width;
$NewHeight=round($height$ratio);
$NewWidth=round($width$ratio);
exec( $mogrify." -resize ".$NewWidth."x".$NewHeight."! $picture");
exec( $mogrify." -crop ".$fixedwidth."x".$fixedheight."+0+0 $picture");
// REFRESH
$img = imagecreatefromjpeg($picture);
$width= imagesx($img);
$height= imagesy($img);
}
// CROP HEIGHT
if($height!=$fixedheight){
$ratio =$fixedheight/$height;
$NewHeight=round($height$ratio);
$NewWidth=round($width$ratio);
exec( $mogrify." -resize ".$NewWidth."x".$NewHeight."! $picture");
exec( $mogrify." -crop ".$fixedwidth."x".$fixedheight."+0+0 $picture");
}
ImageDestroy($img);
}
?>
I looked on the code again, can't find my mistake. Thanks