jamesxg1 Posted January 25, 2009 Share Posted January 25, 2009 I have this code <?php $connect = mysql_connect("localhost","root",""); if (!$connect) { die('Could not connect: ' . mysql_error()); } // some code $sql = "SELECT `id`,`username` FROM `users`"; $query = mysql_query($sql); while ($row = mysql_fetch_assoc($query)) { echo "<a href=\"profile.php?id={$row['id']}\">{$row['username']}</a><br>"; } mysql_close($connect); ?> But im getting this error. Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\memberlist.php on line 11 Any idea's on why ?, I really need this fixed ? James. Link to comment https://forums.phpfreaks.com/topic/142395-solved-need-help-with-mysql_fetch_assoc-anyone/ Share on other sites More sharing options...
gevans Posted January 25, 2009 Share Posted January 25, 2009 You haven't chosen a database; mysql_select_db() Link to comment https://forums.phpfreaks.com/topic/142395-solved-need-help-with-mysql_fetch_assoc-anyone/#findComment-746071 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.