0
PHP Warning: Division by zero in /home/u215177984/public_html/classes/Panel.class.php on line 19 PHP Warning: imagecreatetruecolor(): Invalid image Dimensions in /home/u215177984/public_html/classes/Panel.class.php on line 21
I don’t understand! I tested the site before upar and now decided to give one problem after another. I’m no expert, see!
Panel.class.php
public function upload($tmp, $nome, $largura, $pasta){
$foto = imagecreatefromjpeg($tmp);
$x = imagesx($foto);
$y = imagesy($foto);
$altura = ($largura * $y) / $x;
$novaimg = imagecreatetruecolor($largura, $altura);
imagecopyresampled($novaimg, $foto, 0,0,0,0,$largura, $altura, $x, $y);
imagejpeg($novaimg, "$pasta/$nome");
imagedestroy($novaimg);
imagedestroy($foto);
return ($nome);
}//upload de imagens no painel
Upload.php
<?php
function upload($tmp, $nome, $largura, $pasta){
$foto = imagecreatefromjpeg($tmp);
$x = imagesx($foto);
$y = imagesy($foto);
$altura = ($largura * $y) / $x;
$novaimg = imagecreatetruecolor($largura, $altura);
imagecopyresampled($novaimg, $foto, 0,0,0,0,$largura, $altura, $x, $y);
imagejpeg($novaimg, "$pasta/$nome");
imagedestroy($novaimg);
imagedestroy($foto);
return ($nome);
}
?>
Home.php
<div id="bloco-um">
<?php
foreach($query->selecaoLimit('1') as $post){
?>
<div id="destaque">
<a href="<?php echo $base.'/'.$post['categoria'].'/'.$post['slug']; ?>" title="<?php echo $post['titulo']; ?>">
<img src="posts/<?php echo $post['exibicao']; ?>" width="350" title="<?php echo $post['titulo']; ?>" alt="" height="170" />
<span><?php echo $post['titulo']; ?></span>
</a>
</div><!-- destaque -->
<?php } ?>
<div id="outros-destaques">
<?php
foreach($query->selecaoLimit('1,3') as $postdois){
?>
<div class="outro-destaque">
<a href="<?php echo $base.'/'.$postdois['categoria'].'/'.$postdois['slug']; ?>" title="<?php echo $postdois['postdois']; ?>">
<img src="posts/<?php echo $postdois['exibicao']; ?>" title="<?php echo $postdois['postdois']; ?>" border="0" width="110" height="62" />
<span><?php echo $postdois['titulo']; ?></span>
</a>
</div><!-- outro-destaque -->
<?php } ?>
</div><!-- outros-destaques -->
<div id="tabnav">
<ul id="tab-nav">
<li><a href="#cmt-home">Comentários</a></li>
<li><a href="#mais-visualizados">Mais Visualizados</a></li>
</ul>
<div id="cmt-home" class="tab">
<ul>
<?php
$pegarcomentarios = BD::conn()->prepare("SELECT id_post, nome, LEFT (comentario, 45) AS limitado FROM `comentarios` WHERE status = '1' ORDER BY id DESC LIMIT 5");
$pegarcomentarios->execute();
if($pegarcomentarios->rowCount() == 0){
echo '<p>Não existem comentários no nosso site</p>';
}else{
$numb = '0';
while($coment = $pegarcomentarios->fetchObject()){
$numb++;
$postCom = BD::conn()->prepare("SELECT * FROM `posts` WHERE id = '".$coment->id_post."'");
$postCom->execute();
$fetchPost = $postCom->fetchObject();
?>
<li>
<a href="<?php echo $base.'/'.$fetchPost->categoria.'/'.$fetchPost->slug;?>" title="<?php echo $fetchPost->titulo;?>">
<span class="numb"><?php echo $numb;?></span>
<span class="nam"><?php echo $coment->nome;?></span>
<p><?php echo $coment->limitado;?></p>
</a>
</li>
<?php }} ?>
</ul>
</div><!-- comentarios -->
<div id="mais-visualizados" class="tab">
<ul>
<?php
$maisvisualizados = BD::conn()->prepare("SELECT * FROM `posts` ORDER BY views DESC LIMIT 5");
$maisvisualizados->execute();
$num = '0';
while($postmais = $maisvisualizados->fetchObject()){
$num++;
echo '<li><span>'.$num.'</span><a href="'.$base.'/'.$postmais->categoria.'/'.$postmais->slug.'">'.$postmais->titulo.'</a></li>';
}
?>
</ul>
</div><!-- comentarios -->
</div><!-- tabnav -->
</div><!-- bloco-um -->
<div id="bloco-dois">
<div id="artigos">
<h1>Últimos Artigos</h1>
<?php
foreach($query->selecaoArtigos('4', 'artigos') as $artigo){
?>
<div class="artigo">
<a href="<?php echo $base.'/'.$artigo['categoria'].'/'.$artigo['slug']; ?>" title="<?php echo $artigo['titulo']; ?>">
<img src="posts/<?php echo $artigo['exibicao']; ?>" title="<?php echo $artigo['titulo']; ?>" alt="" border="0" width="110" height="62" />
<span><?php echo $artigo['titulo']; ?></span>
</a>
</div><!-- artigo -->
<?php } ?>
</div><!-- artigos -->
<div id="videos">
<h1>Últimos Vídeos</h1>
<?php
$videos = BD::conn()->prepare("SELECT * FROM `videos` ORDER BY id DESC LIMIT 4");
$videos->execute();
if($videos->rowCount() == 0){
}else{
while($video = $videos->fetchObject()){
?>
<div class="video">
<div class="thumb-vid">
<a href="<?php echo $base;?>/video/<?php echo $video->id;?>" title="<?php echo $video->titulo;?>"><img src="images/play.png" title="<?php echo $video->titulo;?>" alt="" border="0" width="110" height="62" class="play"/></a>
<img src="<?php echo $video->thumb;?>" width="110" alt="" height="62" />
</div>
<span><?php echo $video->titulo;?></span>
</div><!-- VIDEO DESTAQUE -->
<?php }}?>
</div><!-- videos -->
</div><!-- bloco-dois -->
<!-------------------- BLOCO TRES ULTIMO BLOCO ----------------------------->
<div id="bloco-tres">
<h1>Outros Posts</h1>
<?php
foreach($query->selecaoLimit('4,5') as $outros){
?>
<div class="outro">
<a href="<?php echo $base.'/'.$outros['categoria'].'/'.$outros['slug'];?>" title="<?php echo $outros['titulo'];?>">
<img src="posts/<?php echo $outros['exibicao'];?>" width="190" height="108" border="0"/>
<span><?php echo $outros['titulo'];?></span>
<p><?php echo html_entity_decode($query->limitar($outros['conteudo'],50));?></p>
</a>
</div><!-- outro -->
<?php }?>
</div><!-- termina bloco tres -->
This Division by zero is certainly in this line
$altura = ($largura * $y) / $x;
. This should cause the second error, so the problem should be in the functionimagesx($foto)
.– Daniel