I keep getting the following error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource on line 17.

I'm trying to figure out if there's some problem with my SQL query statement, or what. When I try to print $result, nothing is displayed.

I've included my code below. Any help would be greatly appreciated. Thanks!

<?php
    require("include/db_functions.inc.php");
	get_db();
	
	beginSession();
	
	include 'template/header.php';
	echo '<h2>Member List</h2>';
	
	
	$sql = "SELECT MemberName, FirstName, LastName, Website, Location, Timezone, Bio FROM t_Members, t_MemberBio WHERE t_Members.MemberName=t_MemberBio.MemberName ORDER BY MemberName ASC";
	$result = mysql_query($sql, $con);	echo '999999999'.$result;
	$numEntries = 0;

	// Print member list
	echo "<ul class=\"memberlist\">";
	while ($row = mysql_fetch_array($result)) {
		$numEntries += 1;
		echo "<li>$row[MemberName]";
			echo '<ul>';
			echo "<li>$row[FirstName] $row[LastName]</li>";
			echo "<li>$row[Website]</li>";
			echo "<li>$row[Location]</li>";
			echo "<li>$row[Timezone]</li>";
			echo "<li>$row[Bio]</li>";
			echo '</ul>';
		echo '</li>';
	}
	echo '</ul>';
	
	if ($numEntries == 0)
		echo '<p><i>There are no members</i></p>';

    mysql_close($con);
?>

<p>Blog Links
<br />
<a href="show.php">See Blog</a>
<br/>
<a href="write_entry.php">Write Blog Entry</a></p>

<?php include 'template/footer.php'; ?>

Recommended Answers

All 4 Replies

Change this "$result = mysql_query($sql, $con); echo '999999999'.$result;" TO $result = mysql_query($sql,$con) or die(mysql_error()); this should tell you if you have a problem in the sql

Thanks! It turns out I needed to specify MemberName in the SELECT area, since the column is in both tables. It should have been:

$sql = "SELECT t_Members.MemberName, FirstName, LastName, Website, Location, Timezone, Bio FROM t_Members, t_MemberBio WHERE t_Members.MemberName=t_MemberBio.MemberName ORDER BY t_Members.MemberName ASC";
Member Avatar for diafol

Can you use an "INNER JOIN ... ON ..." instead?


//EDIT:

Sorry you must have posted while I still had the editor open.

Thanks! It turns out I needed to specify MemberName in the SELECT area, since the column is in both tables. It should have been:

$sql = "SELECT t_Members.MemberName, FirstName, LastName, Website, Location, Timezone, Bio FROM t_Members, t_MemberBio WHERE t_Members.MemberName=t_MemberBio.MemberName ORDER BY t_Members.MemberName ASC";

hi..once try to use table name before all fields which u want yo fetch... like...

$sql = "SELECT t_Members.MemberName, t_Members.FirstName, t_Members.LastName, t_Members.Website,t_Members. Location, t_Members.Timezone,t_Members. Bio FROM t_Members, t_MemberBio WHERE t_Members.MemberName=t_MemberBio.MemberName ORDER BY t_Members.MemberName ASC";

or

the above one of our frnd said us joins....it is the better method...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.