Jump to content


Photo

MySQL Error


  • Please log in to reply
7 replies to this topic

#1 Immortal55

Immortal55
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 15 March 2006 - 02:45 AM

When I try and get this script to run:

<?

//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>';
    
}

?>

I get this error: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/mitchand/public_html/users.php on line 15

What is wrong?

#2 Leipe_Po

Leipe_Po
  • Members
  • PipPip
  • Member
  • 13 posts
  • Locationnetherlands

Posted 15 March 2006 - 02:50 AM


<?

//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>';
    
}

?>


greetz Leipe_Po
[a href="http://www.synnercity.com" target="_blank"]SynnerCity.com[/a]<=my site

Dont let boards be run by politics, but by experince...

the day that i become guru will be the day i leave this site, better a noob somewhere else than a meaningless guru here

#3 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 15 March 2006 - 02:57 AM

That error means there is something wrong with your query. change this line:

$sql = mysql_query("SELECT * FROM users ORDER BY id DESC");

to:

$sql = mysql_query("SELECT * FROM users ORDER BY id DESC") or die(mysql_error());

then let us know what the error is.

#4 Immortal55

Immortal55
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 15 March 2006 - 03:03 AM

Ah, alright I fixed it, i did not have an id column.....

But now I have it ordering by name:

$sql = mysql_query("SELECT * FROM users ORDER BY name DESC") or die(mysql_error());

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?

#5 Immortal55

Immortal55
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 15 March 2006 - 03:32 AM

anyone?

#6 Immortal55

Immortal55
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 15 March 2006 - 03:47 AM

[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???

#7 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 15 March 2006 - 03:50 AM

change:

echo '<a href="/profile/profile.php?user='.$row['uname'].'>'.$row['uname'].'</a>';

to:

echo "<a href=\"/profile/profile.php?user=" . $row['uname'] . "\">" . $row['uname'] . "</a>";


#8 Immortal55

Immortal55
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 15 March 2006 - 03:53 AM

Oh, wow, thanks a lot that worked.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users