Page 1 of 1

fetch_array error

Posted: Sun Sep 12, 2004 12:54 am
by pinehead18

Code: Select all

$sql = "(SELECT author FROM threads) UNION ALL (SELECT author FROM topics) WHERE tid='$newtid'";
$result = mysql_query($sql,$con);
while($row = mysql_fetch_array($result)) { <-- ERRORS HERE
$author = $row['author'];
		
	
$sql = "SELECT email FROM users WHERE user='$author'";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)) {
				
$email = $row['email'];
	echo $email;
	echo "</p>";	
}	
}
while($row = mysql_fetch_array($result)) { <-- ERRORS HERE That is what it says is wrong.

This is the error.
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
Thank you for your help

Posted: Sun Sep 12, 2004 12:55 am
by feyd
you have an error in your query.

Posted: Sun Sep 12, 2004 9:51 am
by dull1554
try mysql_error()

Posted: Sun Sep 12, 2004 10:45 am
by John Cartwright
to expand on both feyd and dull

Code: Select all

<?php
$result = mysql_query($sql) or die('error: '.mysql_error());
?>