Помощ за тези грешки

Ivkoni_

Registered
f54fc71e66a3b9b0662022604e71eb02_210x358.jpg


Това са ми грешките на самия код.

Ето ми ги и кодевете със съотвения ред:

42:

Код:
$thumbnail = imagecreatetruecolor($new_width,$new_height);

51:

Код:
imagecopyresampled($thumbnail, $img_source, 0, 0, 0, 0, $new_width, $new_height, $img_width, $img_height);

52:

Код:
imagejpeg( $thumbnail, $destination_file, 100 );

54:

Код:
imagedestroy($img_source);

55:

Код:
imagedestroy($thumbnail);
 

vik96

Registered
$new_width,$new_height не са валидни размери...цялата грешка идва от това..я преди тая грешка сложи:
PHP:
echo "w: $new_width h: $new_height";
И виж дали размерите са числа
 

Ivkoni_

Registered
Не знам дали го правя правилно но надписа се смени с:

Код:
w: 0 h: 0
Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /home/zdravets/public_html/gallery/gallery-add.php on line 43

Моля ако някой знае да помога, че ми е спешно тази вечер трябва да свърша.
 

vik96

Registered
Няма как да се създаде картинка с размери 0 и 0...$new_width,$new_height трябва да са по-големи от 1 ,а както виждаш не са!
 

eddyy93

Registered
Постни целия ти код, имаш грешка някаде при взимането на размерите на снимката.

търси функция "getimagesize". Виж правилни ли са зададените променливите.
 

Ivkoni_

Registered
Код:
<?php 
include "config.php";
$idk = $_GET['id'];
$idimg = $_GET['img'];
$theip = $_SERVER['REMOTE_ADDR'];
$ip ="xx.xx.xx.xxx";
   if ( $ip != $theip ){  echo "<center><strong>Записаното IP за достъп в админ панела не съвпада с вашето!</strong></center>";
exit;
} else {
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title><meta http-equiv="Content-Type" content="text/html; charset=windows-1251"><link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<table width="800" height="600" border="0" align="center" cellpadding="0" cellspacing="1" class="tablebg">  <tr>    <td align="left" valign="top" class="row1"><table width="800" height="600" border="0" align="center" cellpadding="0" cellspacing="1" class="tablebg">      <tr>       
 <td width="200" align="center" valign="top" class="row2">
<table width="200" border="0" align="center" cellpadding="0" cellspacing="1" class="tablebg">
<?php function create_thumbnail( $source_file, $destination_file, $max_dimension){   list($img_width,$img_height) = getimagesize($source_file); 
// Get the original dimentions   $aspect_ratio = $img_width / $img_height;    
if ( ($img_width > $max_dimension) || ($img_height > $max_dimension) ) 
// If either dimension is too big...   {       if ( $img_width > $img_height ) // For wide images...       {           $new_width = $max_dimension;           
$new_height = $new_width / $aspect_ratio;       }       
if ( $img_width < $img_height ) // For tall images...       
{           
$new_height = $max_dimension;           
$new_width = $new_height * $aspect_ratio;       
}       else if ( $img_width == $img_height ) // For square images...       
{           
$new_width = $max_dimension;           
$new_height = $max_dimension;       
}       
else { echo "Error reading image size."; return FALSE; }   
}   
 { $new_width = $img_width; $new_height = $img_height; } 
// If it's already smaller, don't change the size.    
// Make sure these are integers.   
$new_width = intval($new_width);   
$new_height = intval($new_height); 
$thumbnail = imagecreatetruecolor($new_width,$new_height); 
// Creates a new image in memory.   
// The following block retrieves the source file.  It assumes the filename extensions match the file's format.   
if ( strpos($source_file,".gif") ) { $img_source = imagecreatefromgif($source_file); }   
if ( (strpos($source_file,".jpg")) || (strpos($source_file,".jpeg")) )   { $img_source = imagecreatefromjpeg($source_file); }   
if ( strpos($source_file,".bmp") ) { $img_source = imagecreatefromwbmp($source_file); }   
if ( strpos($source_file,".png") ) { $img_source = imagecreatefrompng($source_file); }    
// Here we resample and create the new jpeg.   
imagecopyresampled($thumbnail, $img_source, 0, 0, 0, 0, $new_width, $new_height, $img_width, $img_height);   
imagejpeg( $thumbnail, $destination_file, 100 );    
// Finally, we destroy the two images in memory.   
imagedestroy($img_source);   
imagedestroy($thumbnail);

$zaiavka = "SELECT * FROM `kategorii` order by id";
$rez = @mysql_query($zaiavka, $conn) or die("A?aoea!2 ");
echo "<tr class=\"row1\"><td><strong>›</strong> <a href=\"gallery-admin.php\">Начало</a></td></tr>";echo "<tr class=\"row1\"><td><strong><center>Моля изберете категория</center></strong></td></tr>";	
while ( $red = mysql_fetch_array( $rez )){ $kategoriq = $red["kategoriq"];       
$id = $red["id"];      
echo "<tr class=\"row1\"><td><a href=\"gallery-add.php?id=$id\">$kategoriq</a></td></tr>";}
$ip = "127.0.0.1"; 
$theip = $_SERVER['REMOTE_ADDR'];  
if ( $ip == $theip )
{  
echo "<span class=\"style9\">~ <a href=\"gallery-admin.php\">Администрация</a> ~</span><hr>";    
} 
else {		
}
?>        
</table>
</td>        
<td width="600" align="center" valign="top" class="row2">                            
<table width="600" border="0" cellpadding="0" cellspacing="1" class="tablebg">            
<tr class="row1">              
<td>
<?php			
echo "<strong>$text</strong></td>";
$current_dir = ("gallery_images/");
/************************************************************/
echo 
("<table class=\"table\" align=\"center\">
<tr>
<td align=\"center\" colspan=\"4\" class=\"fm\"><b>File Manager</b></td></tr>
<tr>
<td colspan=\"4\" class=\"up\" align=\"center\"><br /><form name=\"form\" enctype=\"multipart/form-data\" method=\"post\" action=\"gallery-add.php\">
<input type=\"file\" name=\"file\">
<input name=\"Send\" type=\"submit\" value=\"Upload\"></form>");
if (is_uploaded_file($HTTP_POST_FILES['file']['tmp_name'])){$upload_dir = $current_dir;$upname = $_FILES['file']['name'];$upname = str_replace(" ","",$upname);
$uptype = $_FILES['file']['type'];
$upsize = $_FILES['file']['size'];
if ( $uptype == 'image/jpeg' || $uptype == 'image/gif'){$new_up_name_big = $upload_dir.$upname;$new_up_name = $upload_dir."small-".$upname;create_thumbnail("$upload_dir$upname","$new_up_name",130); 
$zaqvka = "insert into `snimka` (kategoriq, adresmalka, adresgolqma, text) values ('$thekat', '$new_up_name', '$new_up_name_big', '$snimkat')";
$rez = @mysql_query($zaqvka, $conn) or die("Грешка!");
echo "Вие успешно добавихте снимка към избраната от вас категория . <a href=\"gallery-add.php?id=$thekat\">Назад</a>";		
echo ("<div class=\"u\">Успешно качихте снимка <b>$upname</b> ($uptype)</div>");
echo ("<a href=\"gallery-add.php\">Качи още снимки.</a>");}else{echo ("<div class=\"z\">Файла не може да бъде качен <b>$upname</b> ($uptype)</div><br /><div class=\"u\">Може да качвате само jpeg, gif, html, txt, css, js, zip и rar.</div><br /><br />");
echo ("<META HTTP-EQUIV=\"Refresh\" CONTENT=\"5; URL=file.php\">");exit;
}
if(($upsize < 6250000) && ($upsize!=0)){$upname=strtolower($upname);
copy($file,$upload_dir.$upname);
}
else{echo ("<div class=\"z\">Файла е по голям от 5 MB</div>");}
} 			
?>
</td>            </tr>          </table>          <br>          
<table width="600" border="0" cellpadding="0" cellspacing="1" class="tablebg">            
<tr class="row1">             
 <?php
$zaiavka2 = "SELECT * FROM `snimka` where kategoriq='$idk' order by id";
$rez2 = @mysql_query($zaiavka2, $conn) or die("A?aoea!2 ");
$num = "0"; 	while ( $red2 = mysql_fetch_array( $rez2 )){	$num++;$idm = $red2["id"];
$snimkam = $red2["adresmalka"];       
$text = $red2["text"];    
$snimkag = $red2["adresgolqma"];        
echo "<td><center><a href=\"gallery-admin.php?id=$idk&img=$idm\">
<img src=\"$snimkam\" border=\"0\" width=\"130\" heigh=\"80\"></a></center></td>";
if ( $num == "4"){$num = "0";
echo "</tr><tr class=\"row1\">";} 
else {}}									
?>            
</tr>        </table></td></tr>    </table></td>  </tr></table>
<?php
?>
</body>
</html>

Видях къде е това getimagesize , но как да задам стойности ?
 

Горе