Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Feliphe Felix

Warning: mysql_fetch_assoc() expects parameter 1 to be resource

Recommended Posts

Está dando esse erro na Linha 14 do script que estou usando, Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home/u844214382/public_html/controle/pacotes.php on line 14

 

<?
if(isset($_GET["id"]))
{
$howmany=$_GET["howmany"];
$id=$_GET["id"];
if ($_GET["option"]=="delete"){
include ("config.php");
$tabla2 = mysql_query("SELECT * FROM tb_buyref b, tb_refset r WHERE r.id='$id' AND b.id2='$id'"); // selecciono todos los registros de la tabla usuarios, ordenado por nombre
Linha 14 -> while($registro2 = mysql_fetch_assoc($tabla2)){
$price=$_POST['price'];
$refnum=$_POST['refnum'];
$sets=$_POST['sets'];
mysql_query("DELETE FROM tb_refset WHERE id='$id'") or die(mysql_error());
mysql_query("DELETE FROM tb_buyref WHERE id2='$id'") or die(mysql_error());
echo'<meta http-equiv=refresh content=0;URL=index.php?op=26&editar=sucesso>';
}
}
//------------------------- ---------------------------------------
if ($_GET["option"]=="edit")
{
?>
<?
include ("config.php");
$tabla2 = mysql_query("SELECT * FROM tb_buyref b, tb_refset r WHERE r.id='$id' AND b.id2='$id'"); // selecciono todos los registros de la tabla usuarios, ordenado por nombre
while($registro2 = mysql_fetch_assoc($tabla2)){
$price=$_POST['price'];
$refnum=$_POST['refnum'];
$sets=$_POST['sets'];
if(empty($_POST)){ }else{
mysql_query("UPDATE tb_refset SET howmany='$refnum', price='$price' WHERE id='$id'") or die(mysql_error());
mysql_query("UPDATE tb_buyref SET refnum='$refnum', sets='$sets' WHERE id2='$id'") or die(mysql_error());
echo'<meta http-equiv=refresh content=0;URL=index.php?op=26&editar=sucesso>';
}
?>
<section class="grid_6" style="margin-left: 27%;">
<div class="box">
<div class="title">Editar: </div>
<div class="inside">
<div class="in">
<form id="form_id1" class="formee" method="post" action="index.php?op=26&id=<?= $registro2["id"] ?>&option=edit">
<label>Id:
<input type="hidden" name="id" value="<?= $registro2["id"] ?>"><?= $registro2["id"] ?></label><br>
<label>Quantidades De Indicados: </label>
<input type="text" name="refnum" value="<?= $registro2["refnum"] ?>"id="field1" class="validate[required]" ><br>
<label>Quantidades De Pacotes: </label>
<input type="text" name="sets" value="<?= $registro2["sets"] ?>" id="field2" class="validate[required]" ><br>
<label>Preço </label>
<input type="text" name="price" value="<?= $registro2["price"] ?>" id="field3" class="validate[required]"><br>
<?}?>
<p></p>
<input type="submit" value="Salvar" class="button">
</form>
</div>
</div>
</div>
</section>
<?
}
}else{
?>
<!-- --------------- --------------- -->
<section class="grid_12">
<div class="box">
<div class="title">Pacotes / Planos: Indicados </div>
<div class="inside">
<div class="in">
<?
if(isset($_GET['editar'])=="sucesso"){
echo'<div class="alert succes_msg"><span class="alert_close"></span><strong>Info: </strong>
Plano editado com sucesso!
</div>';
}
if(isset($_GET['adicionar'])=="sucesso"){
echo'<div class="alert succes_msg"><span class="alert_close"></span><strong>Info: </strong>
Placote adicionado com sucesso!
</div>';
}
?>
<div class="ui_tabs ui-tabs ui-widget ui-widget-content ui-corner-all">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="datatable_1">
<thead>
<tr><th class="sorting_asc" rowspan="1" colspan="1" >id</th><th class="sorting" rowspan="1" colspan="1" >Q/Indicados</th><th class="sorting" rowspan="1" colspan="1" >Q/Pacotes</th>
<th class="sorting" rowspan="1" colspan="1">
Preço Por Pacote
</th>
<th class="sorting" rowspan="1" colspan="1">
Editar
</th>
<th class="sorting" rowspan="1" colspan="1">
Excluir
</th>
</tr>
</thead>
<tfoot>
<tr><th rowspan="1" colspan="1">Id</th><th rowspan="1" colspan="1">Q/Indicados</th><th rowspan="1" colspan="1">Q/Pacotes</th>
<th rowspan="1" colspan="1">
Preço Por Pacote
</th>
<th rowspan="1" colspan="1">
Editar
</th>
<th rowspan="1" colspan="1">
Excluir
</th>
</tr>
</tfoot>
<tbody>
<?
$tabla2 = mysql_query("SELECT * FROM tb_buyref WHERE id=1 ORDER BY id ASC"); // selecciono todos los registros de la tabla usuarios, ordenado por nombre
while ($registro2 = mysql_fetch_array($tabla2)) {
$indicados=$registro2['refnum'];
$tabla = mysql_query("SELECT * FROM tb_refset WHERE howmany='$indicados' ORDER BY id ASC"); // selecciono todos los registros de la tabla usuarios, ordenado por nombre
while ($registro = mysql_fetch_array($tabla)) { // comienza un bucle que leera todos los registros y ejecutara las ordenes que siguen
echo "
<tr>
<td>". $registro["id"] ."</td>
<td>". $registro["howmany"] ."</td>
<td>".$registro2['sets']."</td>
<td>". $registro["price"] ."</td>
<td>";
?>
<form method="post" action="index.php?op=26&id=<?=$registro["id"]?>&option=edit">
<input type="submit" value="Editar" class="button">
</form>
</td>
<td>
<form method="post" action="index.php?op=26&id=<?= $registro["id"] ?>&option=delete">
<input type="submit" value="Excluir" class="button red">
</form>
</td>
</tr>
<?
} // fin del bucle de ordenes
}
?>
</tbody>
</table>
</div>
<?}?>
</div>
</div>
</div>
</section>

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

$tabla2 = mysql_query("SELECT * FROM tb_buyref b, tb_refset r WHERE r.id='$id' AND b.id2='$id'");

:seta:

$sql = "SELECT * FROM tb_buyref b, tb_refset r WHERE r.id='$id' AND b.id2='$id'";

// Debug purposes
echo $sql; exit;

$tabla2 = mysql_query($sql);

 

off:

Isso é apenas uma dica para depuração. Não significa que seja "a solução" para o problema específico.

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

Parece ser erro na consulta, já testou a consulta direto no BD?


e vc está conectando no banco de dados antes de chegar nesse script?

Compartilhar este post


Link para o post
Compartilhar em outros sites

tente usar assim

 

 

$tabla2 = mysql_query("SELECT * FROM  tb_buyref b, tb_refset r  WHERE r.id=".$id." AND b.id2=".$id)  or die(mysql_error());

 

o erro é que a query esta vindo vazia, então com mysql_error vai mostrar o que esta errado

Compartilhar este post


Link para o post
Compartilhar em outros sites

tente usar assim

$tabla2 = mysql_query("SELECT * FROM  tb_buyref b, tb_refset r  WHERE r.id=".$id." AND b.id2=".$id)  or die(mysql_error());

o erro é que a query esta vindo vazia, então com mysql_error vai mostrar o que esta errado

Deu isso:

Unknown column 'b.id2' in 'where clause'

Compartilhar este post


Link para o post
Compartilhar em outros sites

Amigo poste suas tabelas pra alguém poder ajudar, senão não tem como.

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.