calmchess Posted July 3, 2010 Share Posted July 3, 2010 I need the following function to get a serialzed array from the database explode strings from the resulting arrays......then splice out 1 index reserialze the new array and put it back in the database.......now the below function does just that the problem is for some reason its splicing out 2 indexes...I also need to preserve duplicates i only want to remove 1 index...i've echoed till my fingers bleed and cannot find the reason.......PLZ help me debug this script. <?php session_start(); include("../secure_php/mod_database.php"); $sql = "select serdata from yahvid.tracku where modname='$_POST[modname]'"; $retval = mysql_query( $sql, $conn ); $row = mysql_fetch_array($retval); $arr0= unserialize($row['serdata']); $_SESSION['test0']=$arr0; for($i=0;$i<count($arr0);$i++){ $arr1=explode(":",$arr0[$i]); if($arr1[0]==$_POST['uname']){ $new_arr0 = array_splice($arr0,$i,1); $ser_arr0 = serialize($arr0); $_SESSION['test1'] =$ser_arr0; $sql1 = "update yahvid.tracku set serdata='$ser_arr0' where modname='$_POST[modname]'"; $retval1 = mysql_query( $sql1, $conn ); break; } } echo "success=success"; ?> Link to comment https://forums.phpfreaks.com/topic/206634-splice-problem/ Share on other sites More sharing options...
calmchess Posted July 3, 2010 Author Share Posted July 3, 2010 never mind..........call off the dogs.............there was a problem with the flash application that calls this php script......it was calling it twice. Link to comment https://forums.phpfreaks.com/topic/206634-splice-problem/#findComment-1080710 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.