Q:

PHP PDO query SQLSTATE[42000] error

I had to build quick pdo query (this is very old site, using framework is not possible), and I have problem when I enter more then one parameter for search. 
(for the single param it is working fine, but combining two or more params will give SQLSTATE[42000] error). 
Complete error:
<br />
<b>Fatal error</b>:  Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or
 access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your
 MySQL server version for the right syntax to use near 'WHERE CUSTPHON.PHONE = '1230001343' 
        GROUP BY CUSTOMER.CUST_ID
        ORDER BY CUST' at line 7' in /home/larrysii/public_html/yaclib/lib/db.php:104

Line 104 in db is for executing query:
public function execute(){
        return $this->stmt->execute();
    }

What is wrong here? 
I am getting data from the form like this (I don't know which param will be used):
$searchParams = [];

    if(strlen($_POST['customerName']) > 2)
        $searchParams['customerName'] = strtolower(strip_tags(trim($_POST['customerName'])));

    if(strlen($_POST['cardNumber']) == 7)
        $searchParams['cardNumber'] = strtolower(strip_tags(trim($_POST['cardNumber'])));

    if(strlen($_POST['phoneNumber']) > 3)
        $searchParams['cardNumber'] = strtolower(strip_tags(trim($_POST['phoneNumber'])));

    if(strlen($_POST['customerAddress']) > 3)
        $searchParams['customerAddress'] = strtolower(strip_tags(trim($_POST['customerAddress'])));

    if(strlen($_POST['customerEmail']) > 2)
        $searchParams['customerEmail'] = strtolower(strip_tags(trim($_POST['customerEmail'])));

And this is how I make query:
$queryArray = [];

    foreach($searchParams as $key => $value):

        switch ($key):
            case 'customerName':
                $queryArray['customerName'] = " WHERE LOWER(CUSTOMER.LAST_NAME) LIKE ? "; 
                break;

            case 'cardNumber':
                $queryArray['cardNumber'] = " WHERE CUSTPHON.PHONE = ? "; 
                break;

            case 'phoneNumber':
                $queryArray['cardNumber'] = " WHERE CUSTPHON.PHONE = ? "; 
                break;

            case 'customerAddress':
                $queryArray['customerAddress'] = " WHERE LOWER(CUSTADDR.ADDRESS) LIKE ? "; 
                break;

            case 'customerEmail':
                $queryArray['customerEmail'] = " WHERE LOWER(CUSTOMER.EMAIL) LIKE ? "; 
                break;

        endswitch;

    endforeach;

Getting the query:
$queryString = implode(' OR ', $queryArray);

    $query1 =  "SELECT CUSTOMER.LAST_NAME,CUSTOMER.DOB,CUSTOMER.EMAIL,CUSTPHON.PHONE,CUSTOMER.CUST_ID,CUSTOMER.DATE_LAST,CUSTOMER.ORD_COUNT
        FROM CUSTOMER
        RIGHT JOIN CUSTPHON
        ON CUSTOMER.CUST_ID=CUSTPHON.CUST_ID
        RIGHT JOIN CUSTADDR
        ON CUSTOMER.CUST_ID=CUSTADDR.CUST_ID
        {$queryString}
        GROUP BY CUSTOMER.CUST_ID
        ORDER BY CUSTOMER.LAST_NAME
        ";

    $pdo->prepareQuery($query1);

    $i = 1;

    foreach($searchParams as $key => $value):

        switch ($key):
            case 'cardNumber':

                $cardNumber = $value;

                if(strlen($value) == 7)
                    $cardNumber = '123' . ( string)$value;

                $pdo->bind($i, $cardNumber);

                break;

            case 'customerName':
            case 'customerEmail':
            case 'customerAddress':
                $pdo->bind($i, "%$value%");
            break;

        endswitch;

        $i++;
    endforeach;

A:

The error seems to be that you have multiple WHERE clauses. 
Try this to build your WHERE clause : 
$queryArray = [];

    foreach($searchParams as $key => $value):

        switch ($key):
            case 'customerName':
                $queryArray['customerName'] = " LOWER(CUSTOMER.LAST_NAME) LIKE ? "; 
                break;

            case 'cardNumber':
                $queryArray['cardNumber'] = " CUSTPHON.PHONE = ? "; 
                break;

            case 'phoneNumber':
                $queryArray['cardNumber'] = " CUSTPHON.PHONE = ? "; 
                break;

            case 'customerAddress':
                $queryArray['customerAddress'] = " LOWER(CUSTADDR.ADDRESS) LIKE ? "; 
                break;

            case 'customerEmail':
                $queryArray['customerEmail'] = " LOWER(CUSTOMER.EMAIL) LIKE ? "; 
                break;

        endswitch;

    endforeach;

And this to build your query : 
$queryString = implode(' AND ', $queryArray); // Or you can use ' OR ', depending on what results you want

$query1 =  'SELECT CUSTOMER.LAST_NAME,CUSTOMER.DOB,CUSTOMER.EMAIL,CUSTPHON.PHONE,CUSTOMER.CUST_ID,CUSTOMER.DATE_LAST,CUSTOMER.ORD_COUNT
    FROM CUSTOMER
    RIGHT JOIN CUSTPHON
    ON CUSTOMER.CUST_ID=CUSTPHON.CUST_ID
    RIGHT JOIN CUSTADDR
    ON CUSTOMER.CUST_ID=CUSTADDR.CUST_ID
    ' . ( $queryString ! = '' ? '  WHERE ' .  $queryString : '') . ' 
    GROUP BY CUSTOMER.CUST_ID
    ORDER BY CUSTOMER.LAST_NAME
    ';

