-3

I am getting an Array to String conversion error

errorCode() --> 00000

errorInfo() --> Array

public function getUserInfoByMail( $userEmail )
{
    if (is_mail($userEmail))
    {
        $sql = $this->db->prepare("SELECT * FROM customer INNER JOIN addresses ON customer.customerid = addresses.customerid WHERE standard='1' AND deleted='0' AND email=:email");
        if ($sql->execute(array(':email' => $userEmail))) 
             return $sql->fetch(PDO::FETCH_ASSOC);
        else 
             throw new Exception("There was a DB-Error!");
    }
    //....
}

Why am I am getting an Array to String conversion error?

4
  • so perhaps $userEmail is an array? Commented Aug 3, 2014 at 12:17
  • Read the php manual for errorInfo. It's an array with SQLState error, errorcode and error message. ch1.php.net/manual/en/pdo.errorinfo.php Commented Aug 3, 2014 at 12:20
  • Can you post the full error message? Commented Aug 3, 2014 at 12:24
  • Fatal error: Uncaught exception 'Exception' with message 'There was a DB-Error!' in C:\...\customer.dao.php:107 Stack trace: #0 C:\...\login.php(107): CustomerDAO->getUserInfoByMail('[email protected]') #1 {main} thrown in C:\...\customer.dao.php on line 107 Commented Aug 3, 2014 at 12:25

2 Answers 2

1
->execute() expects you to send it an array with each element representing each ? in the query.\

The main cause of the problem is by only sending it with 2 elements so it use the array as second...Please see here

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

Comments

0

error code 00000 means, you have no error. Just try to convert the errorCode to int and it will evaluate to false

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.