Page 1 of 1

Fatal error: Call to undefined function: db_fetch_array()

Posted: Mon Mar 14, 2005 5:45 am
by joey85
Hi

does anyone know why i would be getting this?

Fatal error: Call to undefined function: db_fetch_array()

i am connected to the database :?

Thanks

Posted: Mon Mar 14, 2005 5:48 am
by Chris Corbyn
There's no such function in any version of PHP.

Do you mean mysql_fetch_array() ?? :?

http://www.php.net/mysql_fetch_array

Use PHP.net for all function lists and usages...

Posted: Mon Mar 14, 2005 3:14 pm
by joey85
Yeh, but it is defined in a separate file.

Code: Select all

//dblib.php
function db_fetch_array($query) {
     return mysql_fetch_array($query);
}

//config.php
require(&quote;$CONFIG->libdir/dblib.php&quote;);
Having a few other probs with other functions that have been defined but it keeps saying they havent. Should i be using include instead of require maybe??

Posted: Mon Mar 14, 2005 5:25 pm
by Chris Corbyn

Code: Select all

function db_fetch_array($query) {
     return mysql_fetch_array($query);
}
This functions seems incredibly wasteful... all it does is passes it to a pre-defined function... why not just make do with mysql_ftech_array() instead of adding extra code?

You should use either require or include (they just handle slightly differently) but are you actually including the file that contains this function on the page that you're trying to use this function on?

Posted: Mon Mar 14, 2005 8:48 pm
by joey85
Yeh it is wasteful but i didnt program it to start with, i got it off of someone and trying to install it.

i will change them and see if it makes a difference.

But yeh, it is included before it is used. The file that first uses it is itself included.

Kinda like this: where the first call to db_fetch_array is in general.php.

Code: Select all

//dblib.php
function db_fetch_array($query)  {
    return mysql_fetch_array($query);
}

 //config.php
require(&quote;$CONFIG->libdir/dblib.php&quote;);
require(&quote;$CONFIG->libdir/general.php&quote;);
so it should be including it before its used.

Posted: Tue Mar 15, 2005 12:49 am
by feyd
It's an OO concept. It allows the underlaying code to change without changing the calling interface. Although normally, it'd be a method in a class..