0

i am fetching data from a table using

mysql_fetch_aaray

the data is displaying correctly now i want that if data is not exist it will print no data found

i tried with the following code

ghgf

am getting error in mysql_num_rows it shows

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

4 Answers 4

2

From your question I found that in if condition you have not passed resource name properly

mysql_num_rows($result33) instead of `mysql_num_rows($result)` 

This will seems to solve your warning(error)

Sign up to request clarification or add additional context in comments.

1 Comment

there is a chance that your query is not proper,echo your query and fire it in phpmyadmin,just check it works or not
1

Your SQL statement is probably throwing an error which you don't catch.

There might be something wrong with the SQL statement, or the tables don't have the same amout of fields - but those are just two shots in the dark.

To debug this further, try

$sql33="your sql here";
$result33=mysql_query($sql33);

if (!$result) {
    die('Invalid query: ' . mysql_error());
}

Another one, you're referencing a wrong resource in your if-condition:

Change

if (mysql_num_r($result<=0))

to

if (mysql_num_rows($result33<=0))

2 Comments

Still a few problems with if (mysql_num_r($result33<=0)), such as missing "ows" in the function name and passing the Boolean expression $result33 <= 0 to that function.
mysql_num_r is not known to me. Change mysql_num_r to mysql_num_rows.
0

Try this one:

    list($count) = mysql_fetch_row($result33);
if ($count<=0)
{
echo "No Data Found";

}

instead of:

    if (mysql_num_r($result<=0))
{
echo "No Data Found";

}

Comments

0
  1. Function with name mysql_num_r does num exists. Use mysql_num_rows instead. But this is may be a typo.
  2. You are passing result of boolean expression $result<=0 to mysql_num_rows, not a resource. Place brackets correctly:

    if( mysql_num_rows($result)<=0 )

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.