-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?

jww
  • 97,681
  • 90
  • 411
  • 885
Sauerbrei
  • 443
  • 4
  • 14
  • so perhaps `$userEmail` is an array? – Ja͢ck Aug 03 '14 at 12:17
  • Read the php manual for errorInfo. It's an array with SQLState error, errorcode and error message. http://ch1.php.net/manual/en/pdo.errorinfo.php – Charlotte Dunois Aug 03 '14 at 12:20
  • Can you post the full error message? – Charlotte Dunois Aug 03 '14 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('test@test.com') #1 {main} thrown in C:\...\customer.dao.php on line 107 – Sauerbrei Aug 03 '14 at 12:25

2 Answers2

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

Community
  • 1
  • 1
Avinash Babu
  • 6,171
  • 3
  • 21
  • 26
0

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

robue-a7119895
  • 816
  • 2
  • 11
  • 31