Page 1 of 1

Fatal error: Call to undefined function: array_key_exists()

Posted: Mon Sep 29, 2003 6:36 am
by saeen
hello thr
well im gettin this error "Fatal error: Call to undefined function: array_key_exists() in " in a php file .. the parameters provided are right and nuthin seems to be wrong but i dono y control jus doesnt move on from this function...can any one tell me wat can the reason be?
thank u

Posted: Mon Sep 29, 2003 6:42 am
by twigletmac
What version of PHP are you using?

Mac

Posted: Mon Sep 29, 2003 6:42 am
by JayBird
im guessing you are using an older version of PHP!?

That will be your problem. The function had a different name in earlier version - key_exists() i think.

Mark

Posted: Mon Sep 29, 2003 6:55 am
by saeen
im using PHP - 4.0.5
ive also tried the key_exists() function but still i face the same error!!!! actually im modifying code written by someone else and the code is so complicated one file contains thousand lines and it is still passing control to other file which itself contains thousand lines so confusingg:S

Posted: Mon Sep 29, 2003 6:57 am
by JayBird
read the manual here for version info regarding this function
http://se.php.net/manual/en/function.ar ... exists.php

Posted: Mon Sep 29, 2003 7:13 am
by saeen
well i tried both functions but nuthin seems to work:S
ERROR:
Fatal error: Call to undefined function: key_exists() in C:\apache\htdocs\kfp\admin\actions\managecompanies.php on line88
code on line 88:
if (!key_exists($companyId, $companyList)) {
if (sizeof($companyList) > 0) {
$keys = array_keys($companyList);
$companyId = $keys[0];
}

companyId is empty when the first time this condition is executed...but ive also tried to assign it a value b4 passin it on but no use still the same error
}

Posted: Mon Sep 29, 2003 7:48 am
by twigletmac
Basically in the version of PHP you are using neither key_exists() or array_key_exists() are available to you as functions.

I would be trying to upgrade my version of PHP.

Mac

Posted: Mon Sep 29, 2003 8:03 am
by JayBird
possible work around (from the manual)

Code: Select all

function arrayKeyExists($key, $search) { 
   return in_array($key, array_keys($search)); 
}
Mark