Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource

    Hi guys,
    I am fairly new to PHP and mySQL and am still learning the ropes.

    I am getting the following error:
    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/i4visua/public_html/cmsadmin/editmembers.php on line 84

    the purpose of the script is to show the just the names of all the companies in the database using a loop.

    My code is as follows:
    PHP Code:
    82    $query "SELECT * FROM 'members'";
    83    $result mysql_query($query);
    84    $num_results mysql_num_rows($result);
    85    
    86    
    for ($i=0$i <$num_results$i++)
    87    {
    88    $row mysql_fetch_array($result);
    89    echo '<br /> ';
    90    echo stripslashed($row['company']);
    91    
    Any help would be much appriciated

    Regards
    Pete

  • #2
    Regular Coder
    Join Date
    Jan 2006
    Location
    Preston, Lancashire, England
    Posts
    285
    Thanks
    0
    Thanked 0 Times in 0 Posts
    instead of using the mysql_num_rows you can do it like this


    PHP Code:
    $result mysql_query($query);

    while(
    $data mysql_fetch_array($result))
    {
    print 
    $data["company"];

    but i think the problem is the quotes round the table name,

    to see if there is a error do this

    PHP Code:
    $result mysql_query($query) or die(mysql_error()); 

  • #3
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thankyou very much.
    I have one more question, I am trying to pass a varible (namely the ID of the database entry) between two pages using the following:

    PHP Code:
    $output "<a href='memberedit?id=".$row['id']."'>Edit</a>";
    echo 
    $output
    When the link is clicked, I am being taken to the address:
    www.mydomain.com/memberedit?id=
    note the missing ID.
    Can anybody help?
    incase you need it, my query is as follows:
    PHP Code:
    $query "SELECT ID,company FROM `members`"
    Cheers guys
    Pete

  • #4
    Regular Coder
    Join Date
    Jan 2006
    Location
    Preston, Lancashire, England
    Posts
    285
    Thanks
    0
    Thanked 0 Times in 0 Posts
    SELECT ID

    $row['id']

    id is not the same as ID

    it should be $row['ID']

  • #5
    Regular Coder Tyree's Avatar
    Join Date
    Sep 2003
    Posts
    254
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Man, that seems familiar! Oh yeah, it's because the same exact thing is in your other thread.

    Hope you got it straight, bro!
    Matt Tyree
    TyreeOnline
    If I didn't just "make it worse," show me some love! Hit me with the rep points! :) (The white scales icon on the left)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •