Estou com uma página que da o seguinte erro:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in
O trecho do código é o seguinte:
<?php
include 'conn_web.php';
$result = mysql_query("SELECT * from categorias");
?>
<?php
while($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
?>
<td height="21" align="left"><a href="categoria_altera.php?id=<?php echo $row["cate_int"];?>" target="_self"><img src="img/icon-mais.jpg" alt="" width="40" height="36" /></a></td>
<td align="left" class="style4"><div align="left"><?php echo $row["cate_nome"];?></div></td>
</tr>
<?php } ?>
Agradeço se alguém ajudar!
Dificuldades Em Mysql_Fetch_Array
Started By babal, 18/09/2014, 22:52
5 replies to this topic
#1
Posted 18/09/2014, 22:52
#2
Posted 19/09/2014, 20:44
tente trocar essa linha:
por essa:while($row = mysql_fetch_array($result,MYSQL_ASSOC))
while($row = mysql_fetch_array($result))
#3
Posted 22/09/2014, 08:41
Fiz isso mais continua dando erro obrigado!
<?php
while($row = mysql_fetch_array($result))
{
?>
<td height="21" align="left"><a href="categoria_altera.php?id=<?php echo $row["cate_int"];?>" target="_self"><img src="img/icon-mais.jpg" alt="" width="40" height="36" /></a></td>
<td align="left" class="style4"><div align="left"><?php echo $row["cate_nome"];?></div></td>
</tr>
<?php } ?>
</table>
<?php
while($row = mysql_fetch_array($result))
{
?>
<td height="21" align="left"><a href="categoria_altera.php?id=<?php echo $row["cate_int"];?>" target="_self"><img src="img/icon-mais.jpg" alt="" width="40" height="36" /></a></td>
<td align="left" class="style4"><div align="left"><?php echo $row["cate_nome"];?></div></td>
</tr>
<?php } ?>
</table>
#4
Posted 22/09/2014, 23:02
bom.. aqui na verdade tb não fez diferença mas ta funfando ok..
tenta uns "or die" p/ ver se da alguma mensagem de erro melhor..
comente a linha do "include" e adapte onde tem os "XXX":
tenta uns "or die" p/ ver se da alguma mensagem de erro melhor..
comente a linha do "include" e adapte onde tem os "XXX":
<?php mysql_connect("XXX","XXX","XXX") or die(mysql_error()); mysql_select_db("XXX") or die(mysql_error()); $result = mysql_query("SELECT * from categorias") or die(mysql_error()); while($row = mysql_fetch_assoc($result)) { ?> <td height="21" align="left"><a href="categoria_altera.php?id=<?php echo $row["cate_int"];?>" target="_self"><img src="img/icon-mais.jpg" alt="" width="40" height="36" /></a></td> <td align="left" class="style4"><div align="left"><?php echo $row["cate_nome"];?></div></td> </tr> <?php } ?>
#5
Posted 23/09/2014, 22:43
Deu certo cara o or die erro me mostrou que o problema era a conexão não estava conectando com o banco acertei e deu certo Obrigado!
#6
Posted 24/09/2014, 10:20
opa.. legal q deu certo.. sucesso ahe...
1 user(s) are reading this topic
0 membro(s), 1 visitante(s) e 0 membros anônimo(s)