Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Ola a todos, sou novo por aqui se eu estiver na area errada perdão, estou montando um site de vendas na pagina categoria estou com esse seguinte erro que nao consigo resolver.
Parse error: syntax error, unexpected T_ELSE in C:\wamp\www\lojavirtual\admin\categoria.php on line 55
vou postar a pagina
essa nao é o começo da pagina, só postei do php em diante.
<?php
$acao = isset($_GET['acao'])? $_GET['acao']:null;
$id = isset($_GET['id'])? $_GET['id']:null;
{
$sql=mysql_query ('SELECT * from categoria where id_categoria=$id');?>
<form id="form1" name="form1" method="post" action=" <?php echo '$PHP_SELF'?>">
<table width="300" border="1" align="center" cellpadding="2">
<tr>
<td width="95">Categoria</td>
<td width="195"><label>
<input name="txtcategoria" type="text" id="txtcategoria" size="35" />
</label></td>
</tr>
<tr>
<td colspan="2"><label>
<div align="center">
<input type="submit" name="Submit" value="OK" />
</div>
</label></td>
</tr>
</table>
</form>
**<?php } else { ?> essa é a pagina do erro**
<table width="99%" border="1">
<tr>
<td width="89%">Categorias</td>
<td colspan="2"><div align="center">Ação</div></td>
</tr>
<? $sql = mysql_query("select * from categorias");
while ($coluna = mysql_fetch_array($sql)) { ?>
<tr>
<td><? echo $coluna['categoria'] ?></td>
<td width="5%"><img src="../imagens/lapis.gif" width="16" height="16" /></td>
<td width="6%"><img src="../imagens/off.png" width="16" height="16" /></td>
</tr>
<?php } ?>
<tr>
<td colspan="3"><div align="right"><img src="../imagens/inserir.gif" width="55" height="16" /></div></td>
</tr>
</table>
<?php } ?>
<p> </p>
</div></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="2"><? include"rodape.php";?></td>
</tr>
</table>
</body>
</html>Cade o if desse else?
Ola amigo, eu coloquei como voce disse mas mesmo assim o erro continua,
<?php } else if{ ?>
so existe um else se tiver um if antes.
esse fecha chave em vermelho vem da onde?
<?php } else { ?> essa é a pagina do erro
e essa chave perdida vem da onde?
$id = isset($_GET['id'])? $_GET['id']:null;
{destaquei para que voce entenda melhor.
<?php
$acao = isset($_GET['acao'])? $_GET['acao']:null;
$id = isset($_GET['id'])? $_GET['id']:null;
{
$sql=mysql_query ('SELECT * from categoria where id_categoria=$id');?>
<form id="form1" name="form1" method="post" action=" <?php echo '$PHP_SELF'?>">
<table width="300" border="1" align="center" cellpadding="2">
<tr>
<td width="95">Categoria</td>
<td width="195"><label>
<input name="txtcategoria" type="text" id="txtcategoria" size="35" />
</label></td>
</tr>
<tr>
<td colspan="2"><label>
<div align="center">
<input type="submit" name="Submit" value="OK" />
</div>
</label></td>
</tr>
</table>
</form>
**<?php } else { ?> essa é a pagina do erro**
<table width="99%" border="1">
<tr>
<td width="89%">Categorias</td>
<td colspan="2"><div align="center">Ação</div></td>
</tr>
<? $sql = mysql_query("select * from categorias");
while ($coluna = mysql_fetch_array($sql)) { ?>
<tr>
<td><? echo $coluna['categoria'] ?></td>
<td width="5%"><img src="../imagens/lapis.gif" width="16" height="16" /></td>
<td width="6%"><img src="../imagens/off.png" width="16" height="16" /></td>
</tr>
<?php } ?>
<tr>
<td colspan="3"><div align="right"><img src="../imagens/inserir.gif" width="55" height="16" /></div></td>
</tr>
</table>
<?php } ?>
<p> </p>
</div></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="2"><? include"rodape.php";?></td>
</tr>
</table>
</body>
</html>
>
so existe um else se tiver um if antes.
esse fecha chave em vermelho vem da onde?
<?php } else { ?> essa é a pagina do erro
e essa chave perdida vem da onde?
$id = isset($_GET['id'])? $_GET['id']:null;
{
destaquei para que voce entenda melhor.
<?php
$acao = isset($_GET['acao'])? $_GET['acao']:null;
$id = isset($_GET['id'])? $_GET['id']:null;
{
$sql=mysql_query ('SELECT * from categoria where id_categoria=$id');?>
<form id="form1" name="form1" method="post" action=" <?php echo '$PHP_SELF'?>">
<table width="300" border="1" align="center" cellpadding="2">
<tr>
<td width="95">Categoria</td>
<td width="195"><label>
<input name="txtcategoria" type="text" id="txtcategoria" size="35" />
</label></td>
</tr>
<tr>
<td colspan="2"><label>
<div align="center">
<input type="submit" name="Submit" value="OK" />
</div>
</label></td>
</tr>
</table>
</form>
**<?php } else { ?> essa é a pagina do erro**
<table width="99%" border="1">
<tr>
<td width="89%">Categorias</td>
<td colspan="2"><div align="center">Ação</div></td>
</tr>
<? $sql = mysql_query("select * from categorias");
while ($coluna = mysql_fetch_array($sql)) { ?>
<tr>
<td><? echo $coluna['categoria'] ?></td>
<td width="5%"><img src="../imagens/lapis.gif" width="16" height="16" /></td>
<td width="6%"><img src="../imagens/off.png" width="16" height="16" /></td>
</tr>
<?php } ?>
<tr>
<td colspan="3"><div align="right"><img src="../imagens/inserir.gif" width="55" height="16" /></div></td>
</tr>
</table>
<?php } ?>
<p> </p>
</div></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="2"><? include"rodape.php";?></td>
</tr>
</table>
</body>
</html>quem não está entendendo é você!!
ANTES DESSA PRIMEIRA CHAVE, PRECISA DE UM IF.
>
quem não está entendendo é você!!
ANTES DESSA PRIMEIRA CHAVE, PRECISA DE UM IF.
haaa sim ;D realmente eu nao tinha entendido, agora no caso como ficaria o código? com o if?
acho q ficaria assim...
if($id){
........
troque as ocorrencias de <? por <?php, para evitar eventuais erros....>
acho q ficaria assim...
if($id){
........
troque as ocorrencias de <? por <?php, para evitar eventuais erros....
ainda sou iniciante em php entao if ou else eu nao tenho usado só coloquei porque to vendo um tuto, entao no caso eu colocaria aqui?
$id =isset($_GET['id'])? $_GET['id']:null;
Obrigado por tudo.
$id = isset($_GET['id'])? $_GET['id']:null;
if($id){
....>
$id = isset($_GET['id'])? $_GET['id']:null;
if($id){
....
HAAAAAAAAAEEE cara era isso mesmo, funfo legal, PERFEITO agora vai dá pra mim continuar com a aula, muito obrigado a voce e ao evandro ae pela ajuda, pode fechar.
ha e o certo é assim pra quem tiver o mesmo problema
**<?php**
**$acao = isset($_GET['acao'])? $_GET['acao']:null;**
**$id = isset($_GET['id'])? $_GET['id']:null;**
if ($acao) { ....
Cade o if desse else?