mysql_list_fields() and mysql_num_fields() error...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
struggling_student
Forum Newbie
Posts: 15
Joined: Mon Feb 23, 2004 3:51 pm

mysql_list_fields() and mysql_num_fields() error...

Post by struggling_student »

hi

when i try to run this within a function:

$Result = mysql_fetch_field($dbname, $tablename);
$num = mysql_num_fields ($Result);

i get the following errors in my page:

Warning: mysql_list_fields(): Unable to save MySQL query result

and

Warning: mysql_num_fields(): supplied arguement is not a valid MySQL result resource

Can anyone help???!
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

are oyu connecting to the database and quering anything??
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

your using that int he wrong way anyways. First you need to connect to the database, then select a database. then query an SQL statement then you can call mysql_fetch_feilds after getting teh result, and you would use it like:

Code: Select all

$result = mysql_query($SQL);
$f = mysql_fetch_field($result);
http://php.ru.ac.za/manual/en/function. ... -field.php
Post Reply