Categories | Question details Back To List | ||
dataprocessor can not update and I can get the data from database , but don't update data to database, I used myDataProcessor.enableDebug, it show the error is : xml status : correct server response: <br/> <b>Parse error</b>:syntax error, unexpected T_VARIABLE in <b>php\update(live).php</b> on line 59 when I checked the line 59, it hasn't some error, because this is the insert sql code, $sql.= "Values('".$_GET["description"]."',".$_GET["qty"].",'"$_GET["type"]."',".$_GET["cbm"].",".$_GET["width"].",'".$_SESSION["id"]."')"; please help, thank you very much the following code my my testing code. html code <script> mygrid = new dhtmlXGridObject('gridbox'); mygrid.setImagePath("../codebase/imgs/"); var flds = "Description of Good,Package Qty,Type,CBM,Gross Width (kg)"; mygrid.setHeader(flds); mygrid.setInitWidths("393,100,100,100,120"); mygrid.setColAlign("left,right,left,right,right"); mygrid.setColTypes("ed,dyn,ed,dyn,dyn"); mygrid.setColumnIds("description,qty,type,cbm,width") mygrid.setColSorting("str,int,str,int,int"); mygrid.setSkin("light"); mygrid.init(); //============================================================================================ mygrid.loadXML("php/get(live).php"); myDataProcessor = new dataProcessor("php/update(live).php"); myDataProcessor.enableDebug(true); myDataProcessor.enableDataNames(true); myDataProcessor.setVerificator(1) myDataProcessor.setVerificator(3,checkIfNotZero) myDataProcessor.setUpdateMode("off");//available values: cell (default), row, off myDataProcessor.defineAction("error",myErrorHandler); myDataProcessor.setTransactionMode("GET"); myDataProcessor.init(mygrid); </script> php/get(live).php code <?php session_start(); if(!isset($_SESSION["id"])) $_SESSION["id"] = microtime(); require_once("../../common/config.php"); $link = mysql_pconnect($mysql_host, $mysql_user, $mysql_pasw); $db = mysql_select_db ($mysql_db); //XML HEADER //include XML Header (as response will be in xml format) if ( stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ) { header("Content-type: application/xhtml+xml"); //header("Content-type: text/xml"); } echo("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"); //cbm if($_GET["cbm"]==""){ $_GET["cbm"] = "0"; } if(isset($_GET["!nativeeditor_status"]) && trim($_GET["!nativeeditor_status"])=="inserted"){ //INSERT $sql = "Insert into test(description,qty,type,cbm,width,GUID) "; $sql.= "Values('".$_GET["description"]."',".$_GET["qty"].",'"$_GET["type"]."',".$_GET["cbm"].",".$_GET["width"].",'".$_SESSION["id"]."')"; $res = mysql_query($sql); //set value to use in response $newId = mysql_insert_id(); $action = "insert"; }else if(isset($_GET["!nativeeditor_status"]) && $_GET["!nativeeditor_status"]=="deleted"){ //DELETE $d_sql = "Delete from test where id=".$_GET["gr_id"]." and GUID='".$_SESSION["id"]."'"; $resDel = mysql_query($d_sql); //set values to include in response $newId = $_GET["gr_id"]; $action = "delete"; }else{ //UPDATE //update row $sql = " Update test set description='".$_GET["description"]."',qty =".$_GET["qty"].",type = '".$_GET["type"]."',cbm=".$_GET["cbm"].",width =".$_GET["width"]." where book_id=".$_GET["gr_id"]." and GUID='".$_SESSION["id"]."'"; //$sql = "Update test set description=".$_GET["description"].",qty='".$_GET["qty"]."',type='".$_GET["type"]."',cbm=".$_GET["cbm"].",width='".$_GET["width"]."',pub_date=".$_GET["pubdate"]." where book_id=".$_GET["gr_id"]." and GUID='".$_SESSION["id"]."'"; $res = mysql_query($sql); //set values to include in response $newId = $_GET["gr_id"]; $action = "update"; } ?> <!-- response xml --> <data> <?php echo "$newid = ".$newId; if($newId!=0){ print("<action type='".$action."' sid='".$_GET["gr_id"]."' tid='".$newId."'/>"); }else{ print("<action type='error'>SQL query error</action>"); } ?> </data> Answer posted by Support on Jan 07, 2009 15:45 As far as I can see you had miss a dot in next place "Values('".$_GET["description"]."',".$_GET["qty"].",'">>.<<$_GET["type"]."',".$_GET["cbm"].",".$_GET["width"].",'".$_SESSION["id"]."')" |