Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13

Thread: mysql_num_rows

  1. #1
    Senior Member joncom11's Avatar
    Join Date
    Oct 2003
    Posts
    284
    Member #
    3532
    I have something like this:
    PHP Code:
    $sql "SELECT * FROM `place` WHERE `something` = '$var' LIMIT 1;";
    $query mysql_query($sql);
    $numrows mysql_num_rows($query); 
    I've used this EXACT script on other hosts, and it works perfectly fine. But when I use this host, all the sudden I start getting errors like this:
    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/me/public_html/scripts/somefile.php on line 40
    In this example, line 40 would be: $numrows = mysql_num_rows($query);

    Any ideas? I'm really stumped, and it's throughing off alot of my scripts.
    Pixel Fuse - Signature webpage, just a spashpage.
    Flash Frogger - Frogger remake, animated/coded in Flash (incomplete/discontinued)
    Daase Art Studio - Homepage of David Daase, a Canadian landscape artist - image gallery/showcase.
    More links if I think of some...

  2.  

  3. #2
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Try manually referring to the handle you got when opening the connection to MySQL.

    I do agree, at first glance, it looks strange.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  4. #3
    Senior Member joncom11's Avatar
    Join Date
    Oct 2003
    Posts
    284
    Member #
    3532
    What do you mean manually refering to the handle.
    Pixel Fuse - Signature webpage, just a spashpage.
    Flash Frogger - Frogger remake, animated/coded in Flash (incomplete/discontinued)
    Daase Art Studio - Homepage of David Daase, a Canadian landscape artist - image gallery/showcase.
    More links if I think of some...

  5. #4
    Member Victor's Avatar
    Join Date
    Jul 2004
    Posts
    54
    Member #
    6614
    Change the line:
    PHP Code:
    $query mysql_query($sql); 
    to
    PHP Code:
    $query mysql_query($sql) or die(mysql_error()); 
    and you will see where is your error.

  6. #5
    Senior Member rosland's Avatar
    Join Date
    Jul 2003
    Location
    Norway
    Posts
    1,944
    Member #
    2096
    Quote Originally Posted by joncom11
    What do you mean manually refering to the handle.
    PHP Code:
    $conn mysql_connect("$host""$user""$password") or die("Could not connect");

    $query mysql_query($sql,  $conn); 
    You should also add a 'die' statement as Victor suggested, to see if the query itself is failing. If it is, that would explain the supplied argument is not a valid MySQL result resource warning you're receiving.
    S. Rosland

  7. #6
    Senior Member Physt's Avatar
    Join Date
    Jul 2004
    Posts
    255
    Member #
    6655
    Isn't it mysql_numrows ? I'm pretty sure it is..
    www.controlalternate.com - Web resources and free templates. www.chaosconcepts.net - Custom web and graphic design.
    www.blog.chaosconcepts.net - My Blog

  8. #7
    Senior Member rosland's Avatar
    Join Date
    Jul 2003
    Location
    Norway
    Posts
    1,944
    Member #
    2096
    Quote Originally Posted by Physt
    Isn't it mysql_numrows ? I'm pretty sure it is..
    No!
    S. Rosland

  9. #8
    Senior Member Physt's Avatar
    Join Date
    Jul 2004
    Posts
    255
    Member #
    6655
    Ah..I checked http://us2.php.net/manual/en/function.msql-numrows.php .. Turns out it's just an alias for it.. I always just used it as the primary 1.
    www.controlalternate.com - Web resources and free templates. www.chaosconcepts.net - Custom web and graphic design.
    www.blog.chaosconcepts.net - My Blog

  10. #9
    Senior Member joncom11's Avatar
    Join Date
    Oct 2003
    Posts
    284
    Member #
    3532
    i have used:

    $sql = "SELECT * FROM `place` WHERE `something` = '$var' LIMIT 1;";
    $query = mysql_query($sql) or die(mysql_error());
    $numrows = mysql_num_rows($query) or die(mysql_error());

    It does not make a difference, it does not do the "die" function, so it doesn't actually fail. Instead it just outputs the above stated "warning"... the sql connection is good (I use "or die" for everything)... code is good (as far as I know)... I don't know why this would work on a different server but not this one.

    I've also had problems getting an fread script to work properly on this server as well, that has always worked in the past on different server.

    I really don't know how I can troubleshoot this anymore... help!
    Pixel Fuse - Signature webpage, just a spashpage.
    Flash Frogger - Frogger remake, animated/coded in Flash (incomplete/discontinued)
    Daase Art Studio - Homepage of David Daase, a Canadian landscape artist - image gallery/showcase.
    More links if I think of some...

  11. #10
    Member Victor's Avatar
    Join Date
    Jul 2004
    Posts
    54
    Member #
    6614
    create file info.php with
    PHP Code:
    <?php phpinfo(); ?>
    and look at the difference in the options for both working and not workimg hosts.


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 03:47 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com