hi,
what am trying to do is, count the fields (number) of a table.
now ..
when i do it in the following way:
include("connect.class");
$s_table = new db;
$statement="SELECT *FROM table";
$message = "";
#The message prints something if Query Succeeded
$s_table->qdb($statement,"databasename",$message);
$y=$s_table->query;
$row=mysql_fetch_row($y);
$x=count($row);
echo ("The Fields Count is: ".$x);
it works fine ....
and coutns the fields of a table ...
what i cant do is:
i want to use a function so i can enter a database name and table name as arguments in the function and the function uses the prev. mentioned class to connect to database and query it and gets the count of field ...
i did it this way :
include("connect.class");
$s_table = new db;
function cnt_table($tablename,$databasename)
{
$statement="SELECT *FROM ".$tablename;
$message = "";
#The message prints something if Query Succeeded
$s_table->qdb($statement,$databasename,$message);
$y=$s_table->query;
$row=mysql_fetch_row($y);
$x=count($row);
echo ("The Fields Count is: ".$x);
}
cnt_table("table","databasename");
but i keep get the following:
Fatal error: Call to a member function on a non-object
please advice ...
thanks in advance for all of you 🙂
regards,