0

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

2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by mwasif
0

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

0

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?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.