Jump to content

MySQL Error


Immortal55

Recommended Posts

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?
Link to comment
https://forums.phpfreaks.com/topic/4996-mysql-error/
Share on other sites

[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]
Link to comment
https://forums.phpfreaks.com/topic/4996-mysql-error/#findComment-17663
Share on other sites

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?
Link to comment
https://forums.phpfreaks.com/topic/4996-mysql-error/#findComment-17666
Share on other sites

[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???
Link to comment
https://forums.phpfreaks.com/topic/4996-mysql-error/#findComment-17677
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.