Shlomit,

It's hard to tell what's wrong without seeing the code
that is giving you the error, but I do have a
suggestion for you below.

In the meantime, you may find this link helpful:
http://www.php.net/manual/en/function.mysql-num-rows.php

There, the manual says that the function is only good
for the result of a SELECT query.  You may also wish
to look at the comments at the bottom of the page,
where many users detail how they figured something
out. (hey if you figure this out, maybe you'd like to
add one yourself ;)

Usually when this happens, it is because the query was
bad.  If you have a string query that is 'built' with
variables, one of them may have been blank...

A good way to check is to throw in a print/echo
statement to show you what the value of your query is
before the query is executed.  If the query is bad,
the resulting resource is bad, and then
mysql_num_rows(), which takes a resource as an
argument, throws that error.

example:
<?php
  $sql = "SELECT * FROM mytable WHERE userID = '" .
$userID . "'" ;
  echo "<p>value of query: $sql</p>";
  $result = $mysql_query($sql);
?>

Something else to think about - do you need to use
mysql_num_rows?  You probably need to operate on all
the rows returned anyway.  If you want a count of rows
from the database, you can always query for:

  $sql = "SELECT COUNT(*) AS Total FROM mytable";
  $result = mysql_query($sql);
  $a_row = mysql_fetch_array($a_row);
  if (is_array($a_row)) {
    $count = $a_row['Total'];
  }

Although if it's someone else's code, you probably
don't want to go thru the work of changing it.  Other
things that may cause this problem:  The parameters
used in mysql_connect() - are they variables?  are
they empty?  If they are from some application wide
configuration file, perhaps they aren't filled in?

Best of Luck,
CM

--- Afgin Shlomit <[EMAIL PROTECTED]> wrote:
> 
> I install a new solaris computer with
> apache 2.0.48, mod_perl 1.99_12, Perl v5.8.1, PHP
> 4.3.3, MySQL 4.0.15a
> 
> We have a program that use php. it work on the old
> server with php 4.1.2,
> apache 1.23, MySQL 3.23.49. When I run the program
> on the new server I got
> the following error:
> Warning: mysql_num_rows(): supplied argument is not
> a valid MySQL result
> resource in /path/to/php/script/file.php on line 43
> 
> Any Idea why it happen?
>       Shlomit.



__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/

Reply via email to