Jump to content

Why i'm not getting the array after unserializing ?


jd2007

Recommended Posts

i serialize it here :

 

 $db=$_GET[db];
$query2="use $db";
$result2=mysql_query($query2);
$sql = "select * from $_GET[t]";
$result2 = mysql_query($sql);
$num=mysql_num_rows($result2);
$r=0;
$c=0;
$arr=array();
echo "<script src='myareaajax.js'></script><form method='get' ><table border=1><tr>";
for ($b=1; $b<=$num; $b++)
{
$sql2 = "select * from $_GET[t] where id='$b'";
$result4 = mysql_query($sql2);
while ($record = mysql_fetch_assoc($result4)) {
	while (list($fieldname, $fieldvalue) = each ($record)) {
            $c++;
		echo "<td><input type=text id=$c value=$fieldvalue /></td>";
		$arr[]=$fieldvalue;
            
	}
	echo "</tr>";
	}
	$r++;
}
//print_r($arr);
$arr2=serialize($arr);
//echo $arr2;
$table=$_GET["t"];
echo "</table>";
echo "<input type='hidden' name='c' value='$c' />";
  echo "<input type='hidden' name='r' value='$r' />";
  echo "<input type='hidden' name='t' value='$t' />";
  echo "<input type='hidden' name='db' value='$db' />";
  echo "
  <input type='button' name='update' value='Update' onclick=my_area('update.php','db=$db&arr=$arr2&t=$t&c=$c&r=$r','3'); />
  </form><br />";
}

 

then, i unserialize here after sending through ajax:

 

<?php
$c=$_GET["c"];
echo $c;
$r=$_GET["r"];
echo $r;
$t=$_GET["t"];
echo $t;
//$arr=;
echo $db=$_GET["db"]."<br />";
//echo $arr=;
$arr2=unserialize($_GET["arr"]);
echo $arr2;
$d=$c/$r;
$server = mysql_connect('localhost', 'root', 'jd2008') or die(mysql_error());
$db_selected = mysql_select_db($db, $server);
$v=0;
for ($f=1; $f<=$c; $f+=$d)
{
for ($e=1; $e<=$d; $e++)
{
$que.="'$arr2[$v]',";
$v++;
}
echo $que."<br />";
//$num=strrchr($que, ",");
$que=substr($que, 0, strlen($que)-1);
$quet="truncate table $t";
$quet=mysql_query($quet);
$queb="insert into $t values ($que)";
$quec=mysql_query($queb);
$que="";
echo $queb."<br />";
}
?>

 

$arr2 shows nothing when echoed....why...pls help ?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.