I’m trying to save the dats of a simple form to a mysql table.
Here is my piece of code :
function showTest() { dhxWins = new dhtmlXWindows(); testWin = dhxWins.createWindow("testWin", 0, 0, 600, 350); testWin.setText("Ecran de test"); testWin.setModal(true); testWin.denyResize(); testWin.button("close").hide(); testWin.button("park").hide(); testWin.button("minmax").hide(); testForm = testWin.attachForm(); testForm.loadStruct("json/formAddItemDevis.json"); testForm.attachEvent("onChange", function(name, value) { switch(name) { case "type_texte": if (value == 'B') { testForm.showItem('biblio'); testForm.showItem('quantite'); testForm.showItem('prix_unit'); testForm.showItem('prix_total'); }; break; case "biblio": alert (value); break; case "prix_unit": var prix_tot = testForm.getItemValue("quantite") * testForm.getItemValue("prix_unit"); testForm.setItemValue("prix_total", prix_tot); default: break; }; }); testForm.attachEvent("onButtonClick", function(name) { switch(name) { case "pbCancel" : testWin.close(); break; case "pbOK" : testForm.save(); testWin.close(); break; default : break; }; }); devisDP = new dataProcessor("php/devisCorpsTmpPDO.php"); devisDP.init(testForm); };
Here is the code of devisCorpsTmpPDO.php :
'<?php
require_once("…/connector/form_connector.php");
require_once( “…/connector/db_pdo.php”);
require_once(“configPDO.php”);$res = new pdo($srv, $user, $pwd);
$sql = “SELECT type_texte,num_lg,texte,quantite,prix_unit,prix_total FROM devis_corps_tmp”;$form = new FormConnector($res,“PDO”);
$form->set_encoding(“iso-8859-1”);
$form->enable_log(“devisCorpsTmpPDO.log”);
$form->render_sql($sql, “id”, “type_texte,num_lg,texte,quantite,prix_unit,prix_total”);
?>
Here is what I get in the log :
====================================
Log started, 27/08/2018 02:08:01DataProcessor object initialized
1535380151945_type_texte => B
1535380151945_biblio => 2
1535380151945_texte => I’m trying to save the datas of this form in a mysql table
1535380151945_quantite => 3
1535380151945_prix_unit => 12.5
1535380151945_prix_total => 37.5
1535380151945_num_lg =>
1535380151945_!nativeeditor_status => inserted
ids => 1535380151945Row data [1535380151945]
type_texte => B
biblio => 2
texte => I’m trying to save the datas of this form in a mysql table
quantite => 3
prix_unit => 12.5
prix_total => 37.5
num_lg =>
!nativeeditor_status => insertedINSERT INTO devis_corps_tmp(type_texte,num_lg,texte,quantite,prix_unit,prix_total) VALUES (‘B’,’’,‘I’m trying to save the datas of this form in a mysql table’,‘3’,‘12.5’,‘37.5’)
Array to string conversion at C:\wamp64\www\gestion\connector\db_pdo.php line 17
Edit operation finished
0 => action:error; sid:1535380151945; tid:1535380151945;Done in 0.017305135726929s
I have the same problem without PDO.
Here is devisCorpsTmp.php :
’ <?php
require("…/connector/form_connector.php");
require (“configDB.php”);$res=mysql_connect($srv, $user, $pwd);
if (!$res) { die('Connexion impossible: ’ . mysql_error()); }
mysql_select_db($db);$form = new FormConnector($res,“MySQL”);
$form->set_encoding(“iso-8859-1”);
$form->enable_log(“devisCorpsTmp.log”);
$form->render_table(“devis_corps_tmp”, “id_devis”, “type_texte,num_lg,texte,quantite,prix_unit,prix_total”);
?>
Here is the log :
====================================
Log started, 27/08/2018 02:08:36DataProcessor object initialized
1535380511297_type_texte => B
1535380511297_biblio => 2
1535380511297_texte => Here is a second test without PDO
1535380511297_quantite => 5
1535380511297_prix_unit => 14
1535380511297_prix_total => 70
1535380511297_num_lg =>
1535380511297_!nativeeditor_status => inserted
ids => 1535380511297Row data [1535380511297]
type_texte => B
biblio => 2
texte => Here is a second test without PDO
quantite => 5
prix_unit => 14
prix_total => 70
num_lg =>
!nativeeditor_status => insertedINSERT INTO devis_corps_tmp(type_texte,num_lg,texte,quantite,prix_unit,prix_total) VALUES (‘B’,’’,‘Here is a second test without PDO’,‘5’,‘14’,‘70’)
Edit operation finished
0 => action:error; sid:1535380511297; tid:1535380511297;Done in 0.016704082489014s
Please, I need your help.
Best regards