Immortal55 Posted March 15, 2006 Share Posted March 15, 2006 When I try and get this script to run:[code]<?//View Artist List, links to profile. require_once('dbconnect.php'); $conn = db_connect(); $db = @mysql_select_db ("mitchand_studio", $conn) or die ("Registration failure, try again."); $sql = mysql_query("SELECT * FROM users ORDER BY id DESC");//the above line would get all your users, and order them by their Id's// the loop below would then make a link for every user while($row = mysql_fetch_assoc($sql)) { stripslashes(extract($row)); echo '<a href="/profile/profile.php?user='.$uname.'>'.$uname.'</a>'; }?>[/code]I get this error: [b]Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/mitchand/public_html/users.php on line 15[/b]What is wrong? Quote Link to comment Share on other sites More sharing options...
Leipe_Po Posted March 15, 2006 Share Posted March 15, 2006 [code]<?//View Artist List, links to profile. require_once('dbconnect.php'); $conn = db_connect(); $db = @mysql_select_db ("mitchand_studio", $conn) or die ("Registration failure, try again."); $sql = mysql_query("SELECT * FROM users ORDER BY id DESC");//the above line would get all your users, and order them by their Id's// the loop below would then make a link for every user while($row = mysql_fetch_array($sql)) { stripslashes($row); echo '<a href="/profile/profile.php?user='.$row['uname'].'>'.$row['uname'].'</a>'; }?>[/code] Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted March 15, 2006 Share Posted March 15, 2006 That error means there is something wrong with your query. change this line:[code]$sql = mysql_query("SELECT * FROM users ORDER BY id DESC");[/code]to:[code]$sql = mysql_query("SELECT * FROM users ORDER BY id DESC") or die(mysql_error());[/code]then let us know what the error is. Quote Link to comment Share on other sites More sharing options...
Immortal55 Posted March 15, 2006 Author Share Posted March 15, 2006 Ah, alright I fixed it, i did not have an id column.....But now I have it ordering by name:[code]$sql = mysql_query("SELECT * FROM users ORDER BY name DESC") or die(mysql_error());[/code]it shows every member in the DB except the newest added member. So if I have 3 members in the DB only two are shown in the list, if i add a new member, only 3 are show on the list...Why is this? Quote Link to comment Share on other sites More sharing options...
Immortal55 Posted March 15, 2006 Author Share Posted March 15, 2006 anyone? Quote Link to comment Share on other sites More sharing options...
Immortal55 Posted March 15, 2006 Author Share Posted March 15, 2006 [a href=\"http://www.mitchanderson.zenaps.com/users.php\" target=\"_blank\"]http://www.mitchanderson.zenaps.com/users.php[/a]there is a link to my problem......There are 3 users in the table as of now they are, sadf, Mitch, and dtdt. Now Sadf shows up fine, the link and all, then Mitch shows up, but the link to his profile is all messed up, and dtdt dosent show up at all.....what is wrong??? Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted March 15, 2006 Share Posted March 15, 2006 change:[code]echo '<a href="/profile/profile.php?user='.$row['uname'].'>'.$row['uname'].'</a>';[/code]to:[code]echo "<a href=\"/profile/profile.php?user=" . $row['uname'] . "\">" . $row['uname'] . "</a>";[/code] Quote Link to comment Share on other sites More sharing options...
Immortal55 Posted March 15, 2006 Author Share Posted March 15, 2006 Oh, wow, thanks a lot that worked. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.