I am writing a php script for creating serialized array as follow:
$x=Array();
$x[0]=$_GET['fname'];
$x[1]=$_GET['lname'];
$str=serialize($x);
print $str;
$y=$_GET['hf'];
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("formdemo", $con);
$sql="update rohit set data='$str' where fid='$y'";
now I want to append more data on this array. what should I do for that
Thanx
First of all, you do not escape data passed to your script. You have to do it with:
Also you do not need to set index, so:
It will append data to the end of array.
If you want to add new data to the existing serialized array, you need to unserialize it, add data and serialize again: