fetch_array error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pinehead18
Forum Contributor
Posts: 329
Joined: Thu Jul 31, 2003 9:20 pm

fetch_array error

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you have an error in your query.
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

try mysql_error()
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

to expand on both feyd and dull

Code: Select all

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