unserialize help, getting errors
Posted on
16th Feb 2014 07:03 pm by
admin
hi all ,
I got a form with 6 fields (2 input and 4 select box), when the page loads one block is shown and through javascript all the fields can be copied multiple times so I need to store the data in array (got hint from here -> http://www.evolt.org/node/60222 ), I manage to save the data but while displaying i get lot of errors
Notice: unserialize() [function.unserialize]: Error at offset 0 of 1 bytes in C:wampwwwartustestme.php on line 67
Notice: unserialize() [function.unserialize]: Error at offset 9 of 10 bytes in C:wampwwwartustestme.php on line 67
this is my php code
Code: <?php
////////////////////////////function defination///////////////////////
function showMonth()
{
$arr=array("January","February","March","April","May","June","July","August","September","October","November","December");
for($i=0;$i<count($arr);$i++)
{
echo "<option value='".$arr[$i]."'>".$arr[$i]."</option>";
}
}
function showYear()
{
$d=getdate();
$curYear=$d['year'];
for($i=$curYear;$i>($curYear-50);$i--)
{
echo "<option value='".$i."'>".$i."</option>";
}
}
// connect to database
define("HOST","localhost");
define("USER","root");
define("PASS","");
define("DATABASE","artuscom");
$con = mysql_connect(HOST,USER,PASS);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db(DATABASE, $con);
// ends here
// start post
if (isset($_POST['submit']))
{
$org = serialize($_POST['curEmpName']);
$des = serialize($_POST['curEmpDesignation']);
$start_month = serialize($_POST['curEmpStartMonth']);
$start_year = serialize($_POST['curEmpStartYear']);
$end_month = serialize($_POST['curEmpEndMonth']);
$end_year = serialize($_POST['curEmpEndYear']);
$query="Insert into artus_test values('','$org','$des','$start_month','$start_year','$end_month','$end_year')";
$result=mysql_query($query);
if ($result) {
echo 'success';
} else { echo 'something failed...';}
}
// show records
if (isset($_POST['showrecord']))
{
$query='SELECT * FROM artus_test';
$result=mysql_query($query);
while($row = mysql_fetch_assoc($result)){
echo "ID: ".unserialize($row['test_id']).", Organization:".unserialize($row['organ']).", Designation:".unserialize($row['design']).", Start-month:".unserialize($row['start_month']).", Start-year:".unserialize($row['start_year']).", End-month:".unserialize($row['end_month']).", End-year:".unserialize($row['end_year'])."<br/>";
}
}
?>
can anyone help please
238 48
Other php-forum Help on code output My CODE: Code: [Select] echo "<phone>".$line["phone"].&qu
please help HTML Code: Code: <span id="ctl00"><span>
EXplanation help Hey all, I am still fairly new to PHP programming and I am trying to put together a page wher
Not reloading page after php form submit Hello helpful souls out there. You guys have come through for me in the recent past and I'm hoping s
Pre-Fill out a PHP form...?? This is for work actually (geek squad). We have to fill out this online php form at work over and ov
how do i display data on a page from mysql 1 - do i use this code at the top of each of my page i wish to only alow access if there as been a s
Using mysql_real_escape_string for displayed content On my website users can input data into a textarea and it will store it in the mysql database. But,
need help about i store the value of my select statement result to an array and stored it to a variable named $fname
preg-match with a string and numbers Hi, I can't get the expression to work for my preg_match, what I'd like is for it to match the strin
foreach result into a single variable Hi, I have this code... Code: [Select]foreach ($_POST['Interests'] as $interest =&