Hi, I'm actually having some issue regarding serialization.. I'm able to save and update my database using serialized and unserialized, however I'm not able to delete data from this array..
May I know is there any solution to my doubt..
a:8:{i:0;s:6:"tset11";i:1;s:5:"test2";i:2;s:5:"tset3";i:3;s:6:"tset43";i:4;s:4:"test";i:5;s:0:"";i:6;s:4:"test";i:7;s:0:"";}
Cheers
koi_s3ng
delete object from serialized data
Moderator: General Moderators
Re: delete object from serialized data
Unserialize, delete, serialize.
Re: delete object from serialized data
Code: Select all
$Policy_No=$_GET["arrayno"]);
$query ="SELECT Policy_No FROM jos_receipt_items WHERE ReceiptNo =". $ReceiptNo ;
$result=mysql_query($query)or die(mysql_error());
while($row = mysql_fetch_array($result)){
$Policy_No = unserialize($row["Policy_No"]);
foreach($Policy_No as $Policy_Nos => $Policy_Nos_value)
{
if($Policy_Nos == $arrayno)
{
$Policy_No[] = $Policy_Nos_value;
$query2 ="DELETE FROM jos_receipt_items WHERE ReceiptNo=". $ReceiptNo ." AND Policy_No='" . $Policy_Nos_value ."'";
$result2=mysql_query($query2)or die(mysql_error());
}
}
}Re: delete object from serialized data
Did you mean to say $arrayno = $_GET['arrayno'] in the first line? Otherwise you're setting a variable and then setting it to something else a few lines later, and then using an empty variable $arrayno in a check within the loop.
Re: delete object from serialized data
yup.. sorry.. it was a typo.. but even if i changed it to $arrayno = $_GET["arrayno"] i'm still not getting any more..
if i echo out my query this is what i get..
DELETE FROM jos_receipt_items WHERE ReceiptNo=00003 AND Policy_No='tset11'
but when i check my database the object is still not removed..
if i echo out my query this is what i get..
DELETE FROM jos_receipt_items WHERE ReceiptNo=00003 AND Policy_No='tset11'
but when i check my database the object is still not removed..
Re: delete object from serialized data
Try putting single quotes around the 0003
Re: delete object from serialized data
erm sorry.. even if i place single quote for 00003, its still not working.. but is my syntax in my earlier post correct??