我使用下面的脚本进行追加的序列化阵列无法访问数据库,PHP
mysql_select_db("formdemo", $con);
$result=mysql_query("select * from rohit where fid='$y'");
if(mysql_num_rows($result)!=0)
{
if($result)
{
while($row=mysql_fetch_array($result))
{
$n=$row['tags'];
$a=explode(',', $n);
print_r($a);
$cnt=count($a);
$x=unserialize($row['data']);
for($i=0;$i<$cnt;$i++)
{
$d=$_GET[$a[$i]];
array_push($x,$d);
}
array_push($x,"<br/>");
}
}
}
$str=serialize($x);
$sql="update rohit set data='$str' where fid='$y'";
if(!mysql_query($sql,$con))
die(mysql_error());
else
echo "Your data has been updated successfully\n";
当我在第一次运行这个当数据库为空,则给了一个错误: array_push ()期望参数1为数组, 并在数据库中存储值b; 0。在这种情况下我该怎么做。请帮助...
什么是'$ d'?你试图把'$ d'推到'$ x'上,但'$ x'是一个字符串 – JamesHalsall 2012-07-13 13:05:39
是的,所以问题是什么 – 2012-07-13 13:06:50
'$ d'是什么意思? – JamesHalsall 2012-07-13 13:07:41