Skip to content
Advertisement

I’m not using count but my log told me “count syntax error”

I have a request who look like this in PHP:

SELECT 
   CONTACT.NOM, 
   CONTACT.PRENOM,
   CONTACT.TITRE, 
   CONTACT.COMMENT2, 
   CONTACT.TEL, 
   CONTACT.FAX, 
   CONTACT.EMAIL, 
   SERVICES.NOM AS SERV 
FROM 
   CONTACT, SERVICES
WHERE 
   CONTACT.SECLEUNIK = SERVICES.SECLEUNIK AND 
   CONTACT.CLCLEUNIK = :idClient AND 
   (
      CONTACT.NOM LIKE %:nom% COLLATE FRENCH_CI_AI OR 
      CONTACT.PRENOM LIKE %:prenom% COLLATE FRENCH_CI_AI
   )

$prepare->execute(array(
            ':idClient' => $idClient,
            ':nom' => $nomClient

          ));

My logs give me this error:

COUNT field incorrect or syntax error” at /var/www/WebService/src/Controller/DefaultController.php line 893

The line 893 is : ':nom' => $nomClient, I don’t understand why there is a “count” in the error, and don’t know how to resolve it.

Advertisement

Answer

You have to concatenate the like wildcards to the parameters, e.g.:

LIKE '%' + :prenom + '%'
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement