Web Analytics Made Easy -
StatCounter mysql_num_rows - returns 0 - CodingForum

Announcement

Collapse
No announcement yet.

mysql_num_rows - returns 0

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • mysql_num_rows - returns 0

    I have a rather complex query, with about 3 joins.

    It returns 12 rows when I run the SQL code manually via phpMyAdmin.

    However, when I paste it in my webpage, run the query, and call the

    mysql_num_rows()

    function, it returns 0!

    To double-check, I had the program output the text of the query (with variables filled in, etc.) whenever it gave me "the bad news" that no results were found. I pasted that code into phpMyAdmin and, sure enough, 12 rows!

    The PHP script should be finding 12 rows as well, but it doesn't seem to be!

    The apparent contradiction, and not understanding this behavior of mysql_num_rows, is having me figuratively pulling my hair out. It makes no sense!

    Has anyone else had this problem? If my last 1/2 hour of Googling is any indication, I'm guessing "no".

    Thanks in advance,

    Matthew

  • #2
    can you post your code for the call .. e.g.
    PHP Code:
    $q=mysql_query($sql);
    echo 
    mysql_num_rows($q); 
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

    Comment


    • #3
      Originally posted by ChantCd View Post
      To double-check, I had the program output the text of the query (with variables filled in, etc.) whenever it gave me "the bad news" that no results were found. I pasted that code into phpMyAdmin and, sure enough, 12 rows!

      The PHP script should be finding 12 rows as well, but it doesn't seem to be!
      If your query returns the correct results in phpMyAdmin and not in php then there is a bug in your php code.

      To help see what is happening can you do the following:

      PHP Code:
      $query "select blah blah......";

      echo 
      $query; die(); 
      and post the output of the echo statement.

      Comment


      • #4
        can you post the sql? That will probably tell a lot more

        ...webdev's suggestion will do the same thing.

        Comment


        • #5
          Firepages!!! You're alive!

          OMG... I bow to thee great oracle of WAMP on USB

          PS When are you gonna update your bl**dy website with some more cool stuff?!?!?!?
          "Tango says double quotes with a single ( ' ) quote in the middle"
          '$Name says single quotes with a double ( " ) quote in the middle'
          "Tango says double quotes ( \" ) must escape a double quote"
          '$Name single quotes ( \' ) must escape a single quote'

          Comment

          Working...
          X