Click to See Complete Forum and Search --> : ms sql nd php data post problem


muhammad shahid
04-30-2008, 09:32 AM
i am facing problem when try to post data some fields are updated but 2 fields are not updated.
this is stored procedur
UPDATE dbo.categories SET

[name]=@name,
[desc]=@desc,
picturepath=@picturepath,
title=@title,
published=@published,
deleted=@deleted,
parentid=@parentid
WHERE [id]=@id


php coding here
function updateCategoryDetails($valuesArray){
echo "updating";
try{

$this->arrValues = $valuesArray;
$sp=" update dbo.categories set ".$this->arrUpdate[1]."='".$this->arrValues[1]."',[";
$sp.=$this->arrUpdate[2]."]='".$this->arrValues[2]."',";
$sp.=$this->arrUpdate[3]."='".$this->arrValues[3]."',";
$sp.=$this->arrUpdate[4]."='".$this->arrValues[4]."',";
$sp.=$this->arrUpdate[5]."=".$this->arrValues[5].",";
$sp.=$this->arrUpdate[6]."=".$this->arrValues[6].",";
$sp.=$this->arrUpdate[7]."=".$this->arrValues[7];
$sp.=" where ".$this->arrUpdate[0]."=".$this->arrValues[0];
echo "sp==".$sp;
echo "<br>";
$sp = mssql_query($sp,$this->con );

mssql_close($this->con);

$this->errMsg = "Selected Brand updated successfully.";
}
catch(Exception $ex)
{
$this->errMsg = "Brand updation failed! ".$ex;
}
}

chazzy
04-30-2008, 09:38 AM
does the sql look correct when this line executes?

echo "sp==".$sp;

muhammad shahid
04-30-2008, 09:56 AM
Array ( [0] => 4
[1] => ddddd
[2] =>
[3] =>
[4] => shahid
[5] => 0
[6] => 0
[7] => 19
)



index 2 and 3 remains blank and not updated

chazzy
04-30-2008, 10:34 AM
you should probably do a null check in php. if the value's empty, replace it with the literal NULL. this should clear it out from the DB.

muhammad shahid
04-30-2008, 10:54 AM
yes they are checked but i am can post the data from another form using insertinto, but only there is a problem in edit form. i also uncheked and tryed but after uncheking its not working.

chazzy
04-30-2008, 11:10 AM
what?

muhammad shahid
04-30-2008, 11:20 AM
how

muhammad shahid
04-30-2008, 11:29 AM
values are not empty,