Jump to content

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

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.
Link to comment
https://forums.phpfreaks.com/topic/4996-mysql-error/#findComment-17665
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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.