Page 1 of 1

Warning: mysql_fetch_array() expects parameter 1

Posted: Sun Sep 02, 2012 1:14 am
by hcmohr
It must be something simple but I am getting nowhere. Could anybody give me a hand?
Here is the code:

Code: Select all

<?
	  $resultant=mysql_query("SELECT id_poema from poemas where id_seccion IN ($cad_secc) AND id_poema < $poema order by id_poema desc");	   
	  if ($rowant=mysql_fetch_array($resultant));
	  {$result=mysql_query("SELECT id_recitado from recitado where id_poema = ".$rowant['id_poema']);
	    if ($row=mysql_fetch_array($result)) $audio = $row['id_recitado'];  else $audio=false;
	?>
	<a href="index_hc.php?audio=<?php echo $audio ?>&poema=<?php echo $rowant['id_poema'] ?>&libro=<?php echo $id_libro ?>" class="f1">anterior</a>
<?    }     ?>	</td>
<td width="178" bgcolor="#CCCCCC">
	<div align="right">
<?
	  $resultant=mysql_query("SELECT id_poema from poemas where id_seccion IN ($cad_secc) AND id_poema > $poema order by id_poema asc");	   
	  if ($rowant=mysql_fetch_array($resultant));
	  {$result=mysql_query("SELECT id_recitado from recitado where id_poema = ".$rowant['id_poema']);
	    if ($row=mysql_fetch_array($result))
		$audio = $row['id_recitado'];  else $audio=false;
	?>
	<a href="index_hc.php?audio=<?php echo $audio ?>&poema=<?php echo $rowant['id_poema'] ?>&libro=<?php echo $id_libro ?>" class="f1">siguiente</a>
	<?    }     ?>	
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in the four of them.
Help!!!

Re: Warning: mysql_fetch_array() expects parameter 1

Posted: Sun Sep 02, 2012 8:55 am
by social_experiment
The error you are receiving happens when there is a problem with the SQL; you don't give a line number for the error so it's a bit difficult to pin point (since you have 4 instances of mysql_fetch_array() ). Try something like this to find any errors during development

Code: Select all

<?php
 $qry = mysql_query($sql) or die(mysql_error());
?>
This will report the last sql error that occured and help you to narrow things down.

Re: Warning: mysql_fetch_array() expects parameter 1

Posted: Sun Sep 02, 2012 5:24 pm
by hcmohr
Yes, thanks. I did some more work, I am moving along and now I am stuck with this:
Form a previous query, I am bringing data to a pop up window, such as this:

http://www.cuevas-mohr.com/catalog/wind ... 61&libro=2

index_hc.php must use the audio, poema & libro information into the next sql query:

Code: Select all

$result=mysql_query("SELECT nom_poema,Doc_poema FROM poemas WHERE [size=150]id_poema ='$poema'"[/size]);
while ($row=mysql_fetch_array($result))
{
	$nom_poema=utf8_encode($row['nom_poema']); $doc_poema=utf8_encode($row['Doc_poema']);
}
if($audio){
$result4=mysql_query("SELECT nom_interprete,audio FROM recitado WHERE id_recitado = '$audio'");
while($row4=mysql_fetch_array($result4)){
	$media=$row4['audio'];
	$interprete=$row4['nom_interprete'];
	           $result3=mysql_query("SELECT nombre, apellido FROM artista WHERE id_artista ='$interprete'");
			   $row3=mysql_fetch_array($result3);
			   $nominterprete=$row3['nombre']." ".$row3['apellido'];
}
}
$result=mysql_query("SELECT * FROM libro WHERE id_libro ='$libro'");
while($row=mysql_fetch_array($result)){ $nom_libro=utf8_encode($row['titulo']); $id_libro=$row['id_libro']; } 
$cad_secc=false;
$result=mysql_query("SELECT id_secc  FROM secciones WHERE id_libro ='$libro'");
while($row=mysql_fetch_array($result)){ 
	$cad_secc.=$row['id_secc'].",";
} $cad_secc=substr($cad_secc, 0, -1);	
 
$id_album="";
It tells me that the quey is empty. I think I am failing to use a correct syntax at WHERE id_poem ='$poem'" since it's not bringing the information. Neither WHERE id_recitado = '$audio'" nor WHERE id_libro ='$libro'".

Any idea what to try?
Thanks.

Re: Warning: mysql_fetch_array() expects parameter 1

Posted: Sun Sep 02, 2012 9:46 pm
by Celauran
Where are those variables defined? Have you tried echoing the variables to see what they contain?