Jump to content


Photo

Erro Ao Executar Código


  • Faça o login para participar
24 replies to this topic

#1 adriano_tj

adriano_tj

    Novato no fórum

  • Usuários
  • 20 posts
  • Sexo:Não informado

Posted 19/01/2006, 10:12

Se alguem puder ajudar, agradeço, onde estou errando? Ah, o erro que aparece é Parse error: parse error, unexpected $end in C:\www\artigos\index.php on line 81

<?

include("funcoes.php");
$mysql = new artigos;
$mysql->conectar()
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><? echo $site; ?> Artigos - Index</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="artigos.css" rel="stylesheet" type="text/css">
</head>

<body bgcolor="#E2E2E2" text="#000000" leftmargin="0" topmargin="0">
<div align="center"><img src="logo.gif" width="468" height="60"><br>
</div>
<table width="470" align="center">
<tr><td valing="top"><?php
    $resultat=mysql_query("SELECT id FROM pna_artigos");
      if(mysql_num_rows($resultat)>0){
$artnum = mysql_num_rows($resultat);
$num=$nb_artigos;
if($pagina=='') {$pagina=0;}
echo '';
if($pagina>0)
{
echo '<a href="index.php?pagina='.($pagina-$num).'"><font size="1"><b>Anterior</b></font></a>&nbsp;&nbsp;';
}

$result=mysql_query("SELECT COUNT(id) FROM pna_artigos");
$linhap=mysql_fetch_row($result);
$i=1;
while ($i<(($pagina + $num)/$num))
{
  echo '<font face="Verdana, Arial" size="1"><a href="index.php?pagina='.($num*($i-1)).'">'.$i.'</a></font>&nbsp;';
  $i++;
}
echo '<font face="Verdana, Arial" color="black" size="1">Páginas : <b>'.$i.'</b></font>&nbsp;';
$i++;
while ($i<=ceil($artnum/ $num))
{
  echo '<font face="Verdana, Arial" size="1"><a href="index.php?pagina='.($num*($i-1)).'">'.$i.'</a></font>&nbsp;';
  $i++;
}
if($linhap[0]>($pagina+$num))
{
echo '<a href="index.php?start='.($pagina+$num).'"><font size="1"><b>Próxima</b></font></a>&nbsp;';
}
  ?>
  </td></tr><?
  $query = mysql_query("SELECT * FROM pna_artigos ORDER BY id DESC LIMIT $pagina,$num");
  while($artigo=mysql_fetch_array($query)) {
    $titulo=$artigo["titulo"];
    $tamanho=$artigo["tamanho"];
    $visto=$artigo["visto"];
    $art_id=$artigo["id"];
    $data=$artigo["data"];
  ?>
  <tr>
    <td background="pontilhado.gif" height="1" valing="top"></td>
  </tr>
  <tr><td valign="top">

  <tr>
    <td><img src="txt.gif"> <font face="Verdana" size="2"> - <a href="ler.php?id=<? echo $art_id; ?>" style="text-decoration:

none">
    <? echo $titulo; ?></a><br>
      <font size="1">Tamanho: <? echo $tamanho; ?>Kb | Visto <? echo $visto; ?> vezes | Data: <? echo $data;

?></font></font></td>
  </tr>
  <tr>
    <td background="pontilhado.gif" height="1" valing="top"><img src="spacer.gif" width="450" height="1"></td>
  </tr><br><? }
  }
  else {
  print("<font face=Verdana size=1>Nenhum artigo foi cadastrado!</font></td></tr>");
  }
  ?>
</table>
<p align=center><font face=Verdana size=1>Powered by <a href="http://www.testeartigo.com.br/" target="_blank">Testando

Artigos</a></font></p>
</body>
</html>



#2 Paulo Freitas

Paulo Freitas

    ××××××× LRU #456504 ××××××× ××××××× LRM #364686 ×××××××

  • Ex-Admins
  • 5612 posts
  • Sexo:Masculino
  • Localidade:Campinas - SP

Posted 19/01/2006, 10:25

Falta um ; no final da linha 5. ;)

[]’s :DAté mais

#3 adriano_tj

adriano_tj

    Novato no fórum

  • Usuários
  • 20 posts
  • Sexo:Não informado

Posted 19/01/2006, 10:29

Ola

Continua o mesmo erro

#4 ViM

ViM

    Turista

  • Usuários
  • 51 posts
  • Sexo:Não informado
  • Localidade:SJC / SP

Posted 19/01/2006, 10:58

vc colocu fechou 2 chaves, em ves de 1
 <tr>
    <td background="pontilhado.gif" height="1" valing="top"><img src="spacer.gif" width="450" height="1"></td>
  </tr><br><? } ####################AQUI##########
  }
  else {
  print("<font face=Verdana size=1>Nenhum artigo foi cadastrado!</font></td></tr>");
  }
  ?>
</table>
<p align=center><font face=Verdana size=1>Powered by <a href="http://www.testeartigo.com.br/" target="_blank">Testando

Artigos</a></font></p>
</body>
</html>
é só tirar ela

#5 adriano_tj

adriano_tj

    Novato no fórum

  • Usuários
  • 20 posts
  • Sexo:Não informado

Posted 19/01/2006, 11:01

Ola

Continua com mesmo erro, só mudou de linha 81 para 80

#6 Paulo Freitas

Paulo Freitas

    ××××××× LRU #456504 ××××××× ××××××× LRM #364686 ×××××××

  • Ex-Admins
  • 5612 posts
  • Sexo:Masculino
  • Localidade:Campinas - SP

Posted 19/01/2006, 11:40

vc colocu fechou 2 chaves, em ves de 1

Isso está certo, são 2 mesmo. Aliás, o que eu disse em meu tópico também não adiantou em nada, pois aquilo não era considerado um erro (eu não sabia, testei aqui). Aparentemente, não vi mais nenhum erro. Olhei o código inteiro mais de 1 vez, não achei nada. :blink:

[]’s :DAté mais

#7 adriano_tj

adriano_tj

    Novato no fórum

  • Usuários
  • 20 posts
  • Sexo:Não informado

Posted 19/01/2006, 11:55

Ae

Até tentei antes de fechar o table o seguinte fechar a conexao do banco mas também não funcionou.
Se alguem puder ajudar, agradeço

#8 gonacts

gonacts

    "Agora eu tb tenho um Tux..." =D

  • Usuários
  • 1030 posts
  • Sexo:Não informado

Posted 19/01/2006, 12:16

<?
include("funcoes.php");
$mysql = new artigos;
$mysql->conectar();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><? echo $site; ?> Artigos - Index</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="artigos.css" rel="stylesheet" type="text/css">
</head>

<body bgcolor="#E2E2E2" text="#000000" leftmargin="0" topmargin="0">
<div align="center"><img src="logo.gif" width="468" height="60"><br>
</div>
<table width="470" align="center">
<tr>
<td valing="top">
<?php
	$resultat = mysql_query("SELECT id FROM musica")or die(mysql_error());
	
	if(mysql_num_rows($resultat)>0):
	$artnum = mysql_num_rows($resultat);
	$num=$artnum;
	
	if($pagina==''):
	$pagina=0;
	endif;
	
	echo '';
	if($pagina>0):
	echo '<a href="index.php?pagina='.($pagina-$num).'"><font size="1"><b>Anterior</b></font></a>&nbsp;&nbsp;';
	endif;
	
	$result = mysql_query("SELECT COUNT(id) FROM musica") or die(mysql_error());
	$linhap = mysql_fetch_row($result);
	$i=1;
	while ( $i < (($pagina + $num)/$num)):
   echo '<font face="Verdana, Arial" size="1"><a href="index.php?pagina='.($num*($i-1)).'">'.$i.'</a></font>&nbsp;';
   $i++;
	endwhile;
	
	echo '<font face="Verdana, Arial" color="black" size="1">Páginas : <b>'.$i.'</b></font>&nbsp;';
	
	$i++;
	while ($i<=ceil($artnum/$num)):
   echo '<font face="Verdana, Arial" size="1"><a href="index.php?pagina='.($num*($i-1)).'">'.$i.'</a></font>&nbsp;';
   $i++;
	endwhile;
	
	if($linhap[0]>($pagina+$num)):
	echo '<a href="index.php?start='.($pagina+$num).'"><font size="1"><b>Próxima</b></font></a>&nbsp;';
	endif;
?>
  </td></tr>
  <?
  $query = mysql_query("SELECT * FROM musica ORDER BY id DESC LIMIT $pagina,$num") or die(mysql_error());
  while($artigo=mysql_fetch_array($query)):
    $titulo   = $artigo["titulo"];
    $tamanho  = $artigo["tamanho"];
    $visto    = $artigo["visto"];
    $art_id   = $artigo["id"];
    $data     = $artigo["data"];
  ?>
	<tr>
	<td background="pontilhado.gif" height="1" valing="top"></td>
	</tr>
	
	<tr>
	<td valign="top">&nbsp;</td>
	</tr>
	
	<tr>
	<td>
	<img src="txt.gif"> <font face="Verdana" size="2"> - <a href="ler.php?id=<?=$art_id?>" style="text-decoration:none"><?=$titulo?></a><br>
	<font size="1">Tamanho: <?=$tamanho?>Kb | Visto <?=$visto?> vezes | Data: <?=$data?></font></font>
	</td>
	</tr>
	
	<tr>
	<td background="pontilhado.gif" height="1" valing="top"><img src="spacer.gif" width="450" height="1"></td>
	</tr>
	<br>
  <? 
  endwhile;  
  else:
  print "<font face=Verdana size=1>Nenhum artigo foi cadastrado!</font></td></tr>";
  endif;
  ?>
</table>
<p align=center><font face=Verdana size=1>Powered by <a href="http://www.testeartigo.com.br/" target="_blank">Testando Artigos</a></font></p>
</body>
</html>
cara, pelo q eu percebi o seu sistema de paginação estava furado...

vc colocou assim:
$num=$nb_artigos;
mas cade o valor da variavel $nb_artigos?!? :blink:

eu entao passei o valor total de registros q ele encontrou no banco para ela, senao nao conta q vc for fazer na linha:
 $i < (($pagina + $num)/$num
vc nao vai conseguir pq nao vai conseguir dividir por zero, sako?!

tenta ai e se der erro cola o erro aki no forum

Edição feita por: gonacts, 19/01/2006, 12:25.

"Ninguém é tão inteligente que não possa aprender e ninguém é tão burro que não possa ensinar.."
"As dúvidas engrandecem nossa sabedoria, mas não basta somente tirá-las, temos que entendê-las"

#9 adriano_tj

adriano_tj

    Novato no fórum

  • Usuários
  • 20 posts
  • Sexo:Não informado

Posted 19/01/2006, 13:00

Bah o velho valeu pela tentantiva mas não é isso não, ocorreu o mesmo erro. Estou testando tudo localmente será que pode ser isso ?? :(
Eu acho que não tem nada a ver pq mesmo sendo local deveria funfar.

#10 Goku Jr

Goku Jr

    Nilson

  • Usuários
  • 3757 posts
  • Sexo:Masculino

Posted 19/01/2006, 13:34

esta exibindo qual mensagem de erro no momento ?

T+
-----------------------------------------------------------------------
PALMEIRAS - Primeiro campeão do mundo em 1951

#11 adriano_tj

adriano_tj

    Novato no fórum

  • Usuários
  • 20 posts
  • Sexo:Não informado

Posted 19/01/2006, 13:42

Parse error: parse error, unexpected $end in C:\www\artigos\index.php on line [Nº da linha]

Sendo que [Nº da linha] mudava conforme eu fazia as alterações que foram postadas aqui no tópico ...

#12 Goku Jr

Goku Jr

    Nilson

  • Usuários
  • 3757 posts
  • Sexo:Masculino

Posted 19/01/2006, 14:00

Testa este código, eu modifiquei ele um pouquinho :P
OBS: no script tem um número [ 20 ] onde ele representa o total de registros a ser exibido na página.

<?
 include("funcoes.php");
 $mysql = new artigos;
 $mysql->conectar();
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
   <title><? echo $site; ?> Artigos - Index</title>
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
   <link href="artigos.css" rel="stylesheet" type="text/css">
  </head>

 <body bgcolor="#E2E2E2" text="#000000" leftmargin="0" topmargin="0">

 <div align="center"><img src="logo.gif" width="468" height="60"></div>

 <table width="470" align="center">
  <tr>
   <td valing="top">
   <?php
    $SQl = mysql_query("SELECT * FROM pna_artigos");
    if(mysql_num_rows($SQl)>0){
     $PGs = ceil(mysql_num_rows($SQl) / 20);
     if(!isset($_GET['PG'])) { $_GET['PG'] = 0; }
     $Ini = $_GET['PG'] * 20;

     echo ($_GET['PG'] > 0)?'<a href="?PG='.($_GET['PG']-1).'"><font size="1"><b>Anterior</b></font></a>&nbsp;&nbsp;':'';
     for ($X = 1; $X <= ($PGs-1); $X++) {
      echo '<font face="Verdana, Arial" size="1"><a href="?PG='.($X-1).'">'.$X.'</a></font>&nbsp;';
     }
     echo '<font face="Verdana, Arial" color="black" size="1">Páginas : <b>'.($PGs-1).'</b></font>&nbsp;';
     echo ($_GET['PG'] < ($PGs - 1))?'<a href="?PG='.($_GET['PG']+1).'"><font size="1"><b>Próxima</b></font></a>&nbsp;':'';

   ?>
   </td>
  </tr>
  <?
   $Sql = mysql_query("SELECT * FROM pna_artigos ORDER BY id DESC LIMIT $Ini,20");
   while($RRr = mysql_fetch_array($Sql)) {
  ?>
  <tr>
    <td background="pontilhado.gif" height="1" valing="top"></td>
  </tr>
  <tr>
    <td>
     <img src="txt.gif"> <font face="Verdana" size="2"> - 
      <a href="ler.php?id=<?=$RRr['id'];?>" style="text-decoration:none"><?=ucwords($RRr['titulo']);?></a><br>
      <font size="1">Tamanho: <?=$RRr['tamanho'];?>Kb | Visto <?=$RRr['visto']; ?> vezes | Data: <?=$RRr['data'];?>;</font>
     </font>
   </td>
  </tr>
  <tr>
   <td background="pontilhado.gif" height="1" valing="top"><img src="spacer.gif" width="450" height="1"></td>
  </tr>

<?
  }   } else {
    echo "<tr><td><font face='Verdana' size='1'>Nenhum artigo foi cadastrado!</font></td></tr>";
  }
?>

</table>

  <p align='center'>
   <font face='Verdana' size=1>Powered by <a href="http://www.testeartigo.com.br/" target="_blank">Testando Artigos</a></font>
  </p>

  </body>
</html>

T+

Edição feita por: Goku Jr, 19/01/2006, 14:36.

-----------------------------------------------------------------------
PALMEIRAS - Primeiro campeão do mundo em 1951

#13 adriano_tj

adriano_tj

    Novato no fórum

  • Usuários
  • 20 posts
  • Sexo:Não informado

Posted 19/01/2006, 14:04

ERRRRRRRRRRO


Parse error: parse error, unexpected $end in C:\www\artigos\teste.php on line 94

Não vou desistir jamais !!! :P

#14 Goku Jr

Goku Jr

    Nilson

  • Usuários
  • 3757 posts
  • Sexo:Masculino

Posted 19/01/2006, 14:39

Mostra as linhas 90, 91, 92, 93, 94, 95, 96, 97 e 98

e alguma coisa q vc está alterando.

T+
-----------------------------------------------------------------------
PALMEIRAS - Primeiro campeão do mundo em 1951

#15 adriano_tj

adriano_tj

    Novato no fórum

  • Usuários
  • 20 posts
  • Sexo:Não informado

Posted 19/01/2006, 14:53

Ae

Só copiei o código e colei no bloco de notas ... salvando como teste.php cara, sei la o que esta acontecendo




1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq