由于整数而导致SQL请求错误

I have a problem with a sql request (insert). I'm using handsontable to save data in my database. So here is my grid where the user enters the data. The row "Numéro pe" is an numeric field in the database but it's not a required field, so it can be empty !! enter image description here

As I have a lot of grid like this one, I made a generic function which insert the data. So I create a string with the data like this :

foreach($ligne as $key => $elt)
{       
    $values .= '\''.$elt.'\',';


    if ($key == ($cptIdEssai-1))
    {
        $values .= '\''.$id_essai.'\',';
    }
}

And I call the function with this string in parameters and it works perfectly.

But my problem is : as my row "numéro pe" is a numeric, the request doesn't work.

Here is the warning on firebug :

Query failed: ERREUR: invalid syntax with the integer : « » LINE 2: ... ESSAI2','TEST ESSAI2_TRAIT1','TEST ESSAI2_BLOC1','','','');

Pb with the request:

INSERT INTO public.parcelle_elementaire(id_traitement,bloc,id_pe,id_essai,code_traitement,id_bloc,numero_pe,taille_pe,commentaires)
VALUES('TEST ESSAI2_TRAIT1','1','TEST ESSAI2_TRAIT1_1','TEST ESSAI2','TEST ESSAI2_TRAIT1','TEST ESSAI2_BLOC1','','','');

Can someone help me to resolve that please ?

EDIT :

So it's very hard to explain my problem but I'm going to give you more informations with more details step by step.

So :

1- The user enters the data in the grid.

2- When he submits, I send the content of this grid with Ajax and I insert the values in the database.

2.1- I make a first string with the row headers and I get exactly that string :

id_traitement,bloc,id_pe,id_essai,code_traitement ,id_bloc,numero_pe,taille_pe,commentaires

2.2- I make a second string with the data the user wrote and I get this string :

'TEST ESSAI2_TRAIT1','1','TEST ESSAI2_TRAIT1_1','TEST ESSAI2','TEST ESSAI2_TRAIT1' ,'TEST ESSAI2_BLOC1','','',''

So, some data are empty, and it's completly normal.

3- I send this two string in a function to insert the values

insert($champsBase,$values,$tableBDD); //Here is my call

function update($champsDB,$idUpdate,$tableBDD,$idTable) //Here is the function
{
    $conn_string = "host=localhost port=5432 dbname=test_postgre user=postgres password='1234'";
    $dbconn = pg_connect($conn_string);

  $sql = "UPDATE public.".$tableBDD." SET ".$champsDB." WHERE '.$idTable.'='".$idUpdate."'";
$res = pg_query($sql) or die("Pb avec la requete: $sql");

}

4- With the variables (the two strings I made) I have this request (which is working)

INSERT INTO public.parcelle_elementaire(id_traitement,bloc,id_pe,id_essai,code_traitement ,id_bloc,numero_pe,taille_pe,commentaires) VALUES('TEST ESSAI2_TRAIT1','1','TEST ESSAI2_TRAIT1_1','TEST ESSAI2','TEST ESSAI2_TRAIT1' ,'TEST ESSAI2_BLOC1','','','');

But this request doesn't work because the value linked to "numero pe" is a numeric in my database and I send quotes ''. But the value isn't a required field. That's why I don't know how to do.