Categories | Question details Back To List | ||
can not save the value in dataprocessor hi that is my code , I don't know why can't update into database , pls help. thank you. <?php //start session (see get.php for details) session_start(); if(!isset($_SESSION["id"])) $_SESSION["id"] = microtime(); //include db connection settings require_once("../../common/config.php"); $link = mysql_pconnect($mysql_host, $mysql_user, $mysql_pasw); $db = mysql_select_db ($mysql_db); //FUNCTION TO USE IN THE CODE LATER //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=\"utf-8\"?>\n"); //PREPARE VALUES //date //price if($_GET["cbm"]==""){ $_GET["cbm"] = "null"; } if(isset($_GET["!nativeeditor_status"]) && trim($_GET["!nativeeditor_status"])=="inserted"){ //INSERT $sql = "Insert into devanningDetail(houseNo,qty,type,cbm,width,marks,whsLoc,remarks,specialInst,GUID) "; $sql.= "Values('".addslashes($_GET["houseNo"])."',".$_GET["qty"].",'".addslashes($_GET["type"])."',".$_GET["cbm"].",".$_GET["width"].",'".addslashes($_GET["marks"])."','".addslashes($_GET["whsLoc"])."','".addslashes($_GET["remarks"])."','".addslashes($_GET["specialInst"])."','".$_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 devanningDetail where devanningPlan_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 //"Values('".addslashes($_GET["devanningPlan_id"])."','".addslashes($_GET["houseNo"])."',".$_GET["qty"].",'".addslashes($_GET["type"])."',".$_GET["cbm"].",".$_GET["width"].",'".addslashes($_GET["marks"])."','".addslashes($_GET["whsLoc"])."','".addslashes($_GET["remarks"])."','".addslashes($_GET["specialInst"])."','".$_SESSION["id"]."')" $sql = "Update devanningDetail set houseNo='".addslashes($_GET["houseNo"])."',qty=".$_GET["qty"].",type='".addslashes($_GET["type"])."',cbm=".$_GET["cbm"].",width=".$_GET["width"].",marks='".addslashes($_GET["marks"])."',whsLoc='".addslashes($_GET["whsLoc"])."',remarks='".addslashes($_GET["remarks"])."',specialInst='".addslashes($_GET["specialInst"])."' where devanningPlan_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 if($newId!=0){ print("<action type='".$action."' sid='".$_GET["gr_id"]."' tid='".$newId."'/>"); }else{ print("<action type='The error'>SQL query error</action>"); } ?> </data> Answer posted by Support on Jan 12, 2009 02:03 a) please try to replace header("Content-type: application/xhtml+xml"); with header("Content-type: text/xml"); b) please beware that $_SESSION["id"] was used in sample to represent separate datasets for each new session, most probably it is not necessary in your case. c) The error response which you are using print("<action type='The error'>SQL query error</action>"); need custom code on client side to be processed correctly, by default it will be just ignored. |