as fotos nao abrem

Enviada por Cesar 
Cesar
as fotos nao abrem
03 de March de 2015 às 04:40PM
Ola pessoal
Nao sou expert em php, sou iniciante mesmo... e uso scripts prontos onde apenas venho fazendo alguns ajustes para funcionar, mas tem um que estou tentando fazer funcionar mas ta dificil e ja procurei arrumar de tudo que é forma sem sucesso.
O caso é o seguinte... e um sistema de notícias, as fotos carregam para o servidor, ficam no lugar certo, mas nao exibe o thumbs e a foto quando abre a noticia.

as paginas que buscam as imagens sao carregadas dentro de uma pagina principal base.php
tudo esta em uma pasta no meu servicor denominada dominio.com.br/atual

devo postar aqui o codigo completo das paginas?

Obrigado

Cesar
David Sousa
Re: as fotos nao abrem
15 de March de 2015 às 03:34AM
Olá César,

Poste aqui o código da página que carrega as notícias... visualizando o código fica mais fácil ajudar!


Simplificando a Web
http://simplificandoaweb.com
Cesar
Re: as fotos nao abrem
16 de March de 2015 às 03:06PM
arquivo noticia.php

<style>
.align-esquerda { float:left; 0 10px 10px 0; width: 315px; height:220px }
</style>
<table width="625" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="625" height="515" valign="top">
<?php
$id = $_GET['id'];
$y = mysql_query("SELECT * FROM noticias WHERE id='$id'");
while($x = mysql_fetch_array($y)){
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="44" align="center"><table width="100%" border="0" align="center">
<tr>
<td align="left"><h2><?php echo $x['titulo'];?></h2></td>
</tr>
<tr>
<td align="left"><?php echo $x['subtitulo'];?></td>
</tr>

</table></td>
</tr>
<tr>
<td height="12" align="center" background="imagens/divtd.jpg"></td>
</tr>
<tr>
<td height="53" style="border: 1px solid #E8E8E8;">




<table width="97%" border="0" align="center">
<tr>
<td height="54" align="left">

<div class="align-esquerda"><br><img src="thumbs.php?w=300&amp;h=200&amp;imagem=images/noticias/<?php echo $x['foto'];?>" width="300" height="200" /></div>

<p><?php echo $x['conteudo'];?></p>

</td>
</tr>
</table>
<table width="97%" border="0" align="center">
<tr>
<td height="54" align="left">Postado em:
<?php
$var = $x['data'];
$var = explode(" ",$var);
$dia = $var[0];
$hora = $var[1];
$dia = explode("-",$dia);
$data = "$dia[2]/$dia[1]/$dia[0] &agrave;s $hora";
echo "$data";
?></td>
</tr>
</table></td>
</tr>
<tr>
<td height="12" align="center" background="imagens/divtd.jpg"></td>
</tr>
<tr>
<td height="53" style="border: 1px solid #E8E8E8;"><table width="100%" border="0" align="center">
<tr>
<td width="40%" align="left"><img src="imagens/noticias-redesociais.jpg" width="273" height="40" border="0" usemap="#Map" /></td>
<td width="60%" align="left">Link:
<input type="text" onclick="javascript:this.focus();this.select();" value="http://<?php $url = "".$_SERVER['HTTP_HOST']; echo "$url";?>/index.php?pg=conteudo&id=<?php echo $x['id'];?>" size="50" readonly="readonly" /></td>
</tr>
</table></td>
</tr>
</table>
<map name="Map" id="Map">
<area shape="rect" coords="1,1,38,40" href="#" />

<area shape="rect" coords="44,1,84,46" href="javascript:window.print()" />

<area shape="rect" coords="92,1,132,41" href="mailto:?subject=<?php echo $x['titulo'];?>&amp;body=Leia%20a%20not%C3%ADcia:%20http://<?php $url = "".$_SERVER['HTTP_HOST']; echo "$url";?>/index.php?pagina=noticia&id=<?php echo $x['id'];?>"/>

<area shape="rect" coords="139,0,178,47" href="http://www.facebook.com/sharer.php?u=http://<?php $url = "".$_SERVER['HTTP_HOST']; echo "$url";?>/index.php?pagina=noticia&id=<?php echo $x['id'];?>&t=<?php echo $x['titulo'];?> - <?php echo $x['subtitulo'];?>" target="_new" />

<area shape="rect" coords="184,-2,224,43" href="http://promote.orkut.com/preview?nt=orkut.com&tt=<?php echo $x['titulo'];?> - <?php echo $x['subtitulo'];?> &du=http://<?php $url = "".$_SERVER['HTTP_HOST']; echo "$url";?>/index.php?pagina=noticia&id=<?php echo $x['id'];?>&tn=http://<?php $url = "".$_SERVER['HTTP_HOST']; echo "$url";?>/images/noticias/<?php echo $x['foto'];?>" target="_new" title="Compartilhar not&iacute;cia com amigos do orkut!" />


<area shape="rect" coords="231,0,272,44" href="http://twitter.com/home?status=<?php echo $x['titulo'];?> - <?php echo $x['subtitulo'];?>" target="_new" />
</map>

<?php } ?>

<br />
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="30" align="left" bgcolor="#F0F0F0"><strong>&nbsp;&bull; News | Outras Noticias</strong></td>
</tr>
</table>
<?php $y = mysql_query("SELECT * FROM noticias WHERE tipo='noticias' ORDER BY RAND() LIMIT 10");
while($x = mysql_fetch_array($y)){
?>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="12" align="center" background="imagens/divtd.jpg"></td>
</tr>
<tr>
<td width="53%" height="24" align="left" class="mause-noticia" onMouseOver="this.className='mause-noticia2';" onMouseOut="this.className='mause-noticia';">
<a style="color:#666" href="index.php?pagina=noticia&id=<?php echo $x['id'];?>">
<?php $var = $x['data'];
$var = explode(" ",$var);
$dia = $var[0];
$hora = $var[1];
$dia = explode("-",$dia);
$data = "$dia[2]/$dia[1]/$dia[0]";
echo "<b>$data</b>";
?> -

<?php $titulon = $x['titulo']; echo substr($titulon,0, 70)."...";?>
</a> </td>
</tr>
</table>
<?php } ?>

</td>
</tr>
</table>


arquivo noticias.php

<table width="622" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="622" height="939" valign="top">

<?php
$categoria = $_GET['categoria'];
$banco = mysql_select_db("fa");
$busca = "SELECT * FROM noticias WHERE tipo='$categoria' ORDER BY ID DESC";
$total_reg = "7";

$paginacao = $_GET['pags'];
if (!$paginacao) {
$pc = "1";
} else {
$pc = $paginacao;
}
$inicio = $pc-1;
$inicio = $inicio*$total_reg;

$limite = mysql_query("$busca LIMIT $inicio,$total_reg");
$todos = mysql_query("$busca");
$maxRec = mysql_num_rows($todos);
$tr = mysql_num_rows($todos);
$tp = $tr / $total_reg;
$tp = (int) $tp;

if ($tp!=($tr / $total_reg)) { $tp++; }

while($x = mysql_fetch_array($limite)) {

if (($i%2)==0) { $bgcolor="#F3F3F3"; } else { $bgcolor="#FFFFFF"; }

?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="9" align="center" background="imagens/div_recadomural.jpg"></td>
</tr>
<tr>
<td height="108" align="center" style="border: 1px solid #E8E8E8;" bgcolor='<?=$bgcolor?>'>


<table width="559" border="0">
<tr>
<td width="80" rowspan="4" align="center">

<?php $imagem = $x["foto"];
if($x[foto] == "$imagem")
{
$resultado = "<img src='thumbs.php?w=80&amp;h=70&amp;imagem=images/noticias/$imagem'/>";
}
if($x[foto] == "")
{
$resultado = "<table width='80' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td height='70' bgcolor='#333333' style='color:#FFF'>
Sem Foto
</td>
</tr>
</table>";
}
echo "$resultado";
?>

</td>
<td width="469" align="left">
<span style="text-transform: uppercase;"><b>
<a href="index.php?pagina=noticia&id=<? echo "$x[id]"; ?>"><? echo "$x[titulo]"; ?></a>
</b></span>

</td>
</tr>
<tr>
<td align="left"><a href="index.php?pagina=noticia&id=<? echo "$x[id]"; ?>"><? echo "$x[subtitulo]"; ?></a></td>
</tr>
<tr>
<td align="left">
<?php
$var = $x['data'];
$var = explode(" ",$var);
$dia = $var[0];
$hora = $var[1];
$dia = explode("-",$dia);
$data = "$dia[2]/$dia[1]/$dia[0] &agrave;s $hora";
echo "$data";
?></td>
</tr>
<tr>
<td align="left">


</td>
</tr>
</table>

</td>
</tr>
</table>
<?php $i++; }

echo "<br><center>Total de <font color=red>$maxRec</font> Noticias Encontradas</center><br>";


if ($tp > 1) {
$anterior = $pc -1;
$proximo = $pc +1;
echo "<center><FONT SIZE=1 face=Verdana>";
if ($pc>1) { echo "<a href='base.php?pagina=noticias&pags=$anterior".$comp."'><<< Anterior</a> "; } else { echo "<<< Anterior"; }
echo " | ";

if ($tp <= 23)
{ $cont1 = 1; $cont2 = $tp; }
else
{ if ($pc < 19 )
{ $cont1 = 1; $cont2 = 23; }
else
{ $cont2 = $pc + 18;
if ($cont2 > $tp)
{ $cont2 = $tp; }
$cont1 = $cont2 - 22;
}
}
$cont2++;
$cont=$cont1;


while ($cont!=$cont2) {
if ($pc==$cont){
echo (" <font color=red>[$cont]</font> | ");
} else {
echo (" <A HREF=\"base.php?pagina=noticias&pags=$cont".$comp."\">$cont </A> | ");
}
$cont++;
}
if ($pc<$tp) {
echo " <a href='base.php?pagina=noticias&pags=$proximo".$comp."'>Próxima >>></a>";
} else {
echo "Próxima >>>";
}
echo "</font></center>";
}
?>

</td>
</tr>
</table>


arquivo thumbs.php
<?
header("Content-type: image/jpeg");
$im = imagecreatefromjpeg($_GET['imagem']); // Cria uma nova imagem a partir de um arquivo ou URL

$wid = (int)$_GET["w"];
$hei = (int)$_GET["h"];


$w = imagesx($im);
$h = imagesy($im);

$w1 = $w / $wid;
if ($hei == 0)
{
$h1 = $w1;
$hei = $h / $w1;
}
else
{
$h1 = $h / $hei;
}
// echo "$h1 - $w1";
$min = min($w1,$h1);

$xt = $min * $wid;
$x1 = ($w - $xt) / 2;
$x2 = $w - $x1;

$yt = $min * $hei;
$y1 = ($h - $yt) / 2;
$y2 = $h - $y1;

$x1 = (int) $x1;
$x2 = (int) $x2;
$y1 = (int) $y1;
$y2 = (int) $y2;

$img = NULL;

$img = imagecreatetruecolor($wid, $hei);
//$background = imagecolorallocate($img, 50, 50, 50);
imagecolorallocate($img,255,255,255);

$c = imagecolorallocate($img,255,255,255);
$c1 = imagecolorallocate($img,0,0,0);

for ($i=0;$i<=$hei;$i++)
{
imageline($img,0,$i,$wid,$i,$c);
}

imagecopyresampled($img,$im,0,0,$x1,$y1,$wid,$hei,$x2-$x1,$y2-$y1);

imagejpeg($img, '', 95)
?>
Você precisa estar logado no PHPBrasil.com para poder enviar mensagens para os nossos fóruns.

Faça o login aqui.