Denunciar [Resolvido] ERRO mysql_fetch_array em PHP Postado Maio 30, 2016 · Editado Maio 30, 2016 por callixton Resolvido Estou tendo o seguinte erro que não ando conseguindo solucionar. Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in linha 43 " while($linhas = mysql_fetch_array($resultado)){ ?> " alguém me da uma forcinha ou um tranco? <?php session_start(); include("conexao.php"); $resultado=mysql_query("SELECT * FROM categorias ORDER BY 'id'"); $linhas=mysql_num_rows($resultado); ?> <html lang="pt-br"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="css/bootstrap.min.css" rel="stylesheet"> <title>Lista de Categorias</title> </head> <body> <!-- Fixed navbar --> <?php include("menuAdmin.php"); ?> <div class="container theme-showcase" role="main"> <div class="page-header"> <h1>Lista de Categoria</h1> </div> <div class="row espaco"> <div class="pull-right"> <a href="cad_categoria.php"><button type='button' class='btn btn-sm btn-success'>Cadastrar</button></a> </div> </div> <div class="row"> <div class="col-md-12"> <table class="table"> <thead> <tr> <th>ID</th> <th>Nome</th> <th>Ações</th> </tr> </thead> <tbody> <?php while($linhas = mysql_fetch_array($resultado)){ ?> <!--echo "<tr>";--> <tr> <td><?php echo $rows['id']; ?></td> <td><?php echo $rows['nome']; ?></td> <td> <a href='visual_categoria.php&id=<?php echo $rows['id']; ?>'><button type='button' class='btn btn-sm btn-primary'>Visualizar</button></a> <a href='editar_categoria.php&id=<?php echo $rows['id']; ?>'><button type='button' class='btn btn-sm btn-warning'>Editar</button></a> <a href='classes/apagar_categoria.php?id=<?php echo $rows['id']; ?>'><button type='button' class='btn btn-sm btn-danger'>Apagar</button></a> </tr> <?php //echo "</tr>"; } ?> </tbody> </table> </div> </div> </div>
[Resolvido] ERRO mysql_fetch_array
em PHP
Postado · Editado por callixton
Resolvido
Estou tendo o seguinte erro que não ando conseguindo solucionar.
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in linha 43 " while($linhas = mysql_fetch_array($resultado)){ ?>
"
alguém me da uma forcinha ou um tranco?
<?php
session_start();
include("conexao.php");
$resultado=mysql_query("SELECT * FROM categorias ORDER BY 'id'");
$linhas=mysql_num_rows($resultado);
?>
<html lang="pt-br">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/bootstrap.min.css" rel="stylesheet">
<title>Lista de Categorias</title>
</head>
<body>
<!-- Fixed navbar -->
<?php
include("menuAdmin.php");
?>
<div class="container theme-showcase" role="main">
<div class="page-header">
<h1>Lista de Categoria</h1>
</div>
<div class="row espaco">
<div class="pull-right">
<a href="cad_categoria.php"><button type='button' class='btn btn-sm btn-success'>Cadastrar</button></a>
</div>
</div>
<div class="row">
<div class="col-md-12">
<table class="table">
<thead>
<tr>
<th>ID</th>
<th>Nome</th>
<th>Ações</th>
</tr>
</thead>
<tbody>
<?php
while($linhas = mysql_fetch_array($resultado)){ ?>
<!--echo "<tr>";-->
<tr>
<td><?php echo $rows['id']; ?></td>
<td><?php echo $rows['nome']; ?></td>
<td>
<a href='visual_categoria.php&id=<?php echo $rows['id']; ?>'><button type='button' class='btn btn-sm btn-primary'>Visualizar</button></a>
<a href='editar_categoria.php&id=<?php echo $rows['id']; ?>'><button type='button' class='btn btn-sm btn-warning'>Editar</button></a>
<a href='classes/apagar_categoria.php?id=<?php echo $rows['id']; ?>'><button type='button' class='btn btn-sm btn-danger'>Apagar</button></a>
</tr>
<?php
//echo "</tr>";
}
?>
</tbody>
</table>
</div>
</div>
</div>