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
pinehead18
Forum Contributor
Posts: 329 Joined: Thu Jul 31, 2003 9:20 pm
Post
by pinehead18 » Sun Sep 12, 2004 12:54 am
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
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Sep 12, 2004 12:55 am
you have an error in your query.
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 » Sun Sep 12, 2004 9:51 am
try mysql_error()
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Sun Sep 12, 2004 10:45 am
to expand on both feyd and dull
Code: Select all
<?php
$result = mysql_query($sql) or die('error: '.mysql_error());
?>