1

(Disclaimer) MY php experience is approx 2 hours old and I have know idea what I am doing.

This is my error and I am wondering how do you know where the error is, for example.

as rendered in my browser, this is my error.

Fatal error: Call to undefined function array_key_exist() in 
/home/mjcrawle/public_html/cit/home/processlogin.php on line 47

Line 47 is actually if (array_key_exist('submit', $_post)){

I do not know if the error is before or after - this is my code.

/*Determine if the form data was submitted*/
if (array_key_exist('submit', $_post)){
    /*this removes left over data*/
    $emailaddress = sanitize($_post['emailaddress']);
    $password = sanitize($_POST['password']);

    /*verify form data*/
    $auth_status = validateLogin($emailaddress, $password); 
}
5
  • 1
    Almost in all cases the error points to the line on where the error is, like in your case with a wrong function name. PS: variables are case sensitive, $_POST != $_post Commented Feb 5, 2011 at 12:47
  • The array_key_exists snippet originates in a bad tutorial. Use isset($_POST["submit"]) or just if ($_POST["submit"]) if you want debug information. Also I have a hunch the sanitize() function might not be a stellar implementation either. Commented Feb 5, 2011 at 12:52
  • @mario why is array_key_exists bad? The only difference is that isset returns false if a variable is set to null. Commented Feb 5, 2011 at 12:56
  • 1
    @meze: Entries in $_GET or $_POST are never going to contain NULL anyway. There are empty strings at best. Hence a normal boolean check is sufficient; testing for the key is overdoing it. Commented Feb 5, 2011 at 12:58
  • ⁺¹ cuz you were the first of ≈800 peoples who mistyped the function. Commented Feb 17, 2015 at 9:35

3 Answers 3

7

The function is array_key_exists, not array_key_exist :).

emphasis on the latter s

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks... Wow, Looks like I am in for a long day.
2

function name is array_key_exists() (your forgot S in "exists")

Comments

0

The error is saying that the function array_key_exist doesn't exist - reason for this is because you forgot to add an 's' at the end. The actual function name is array_key_exists.

Try this:

/*Determine if the form data was submitted*/
if (array_key_exists('submit', $_post)){

  /*this removes left over data*/
  $emailaddress = sanitize($_post['emailaddress']);
  $password = sanitize($_POST['password']);

  /*verify form data*/
  $auth_status = validateLogin($emailaddress, $password);
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.