hello

i have the following code

<?php
mysql_connect("localhost", "lekan", "") or die(mysql_error());
echo "connected to database";
mysql_select_db("today") or die(mysql_error());
echo "Connected to database<br>";
$tables=mysql_list_tables("today");
if ($tables ==""){
echo "this database does not have a table";
exit;
}else {
echo $tables;
}
//number of rows
$row_num = mysql_num_rows('first name');
if (!$row_num){
echo "This table does not have any row";
exit;
}
else{
echo $row_num;
}

mysql_close();
echo "Connection is closed";

?>

but rather than echo out the rows and tables this is what i get
connected to database
Connected to database
Resource id #3
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\database\db3.php on line 14
This table does not have any row

please can anybody tell me where i am getting it wrong. thanks alot

Recommended Answers

All 3 Replies

Replace $row_num = mysql_num_rows('first name'); with $row_num = mysql_num_rows($tables);

thanks for your help but what i now have is
connected to database
Connected to database
Resource id #32
Connection is closed

what else should i do?

Please post your full code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.