PHP unserialize error when deserializing jQuery serialized form
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/6164691/what-to-do-with-php-after-jquery-serialize">What to do with php after jquery .serialize()</a>  </p>
</blockquote>



<p>I am serializing the following form using jQuery, sending it to the server using ajax and deserializing using PHP.</p>

<p>When I deserializing I get the error:</p>

<p><code>Error at offset 0 of 39 bytes</code></p>

<pre><code>&lt;form  id="Marriage" style="display: none"&gt;
  &lt;input type="text" name="city" class="txtt" value="city"/&gt;
  &lt;input type='button' value='Apply' id="msendsend" class="sendaf" name="jobforming"/&gt;
&lt;/form&gt;
</code></pre>

<p>Here is the jquery function to send this form</p>

<pre><code>  $(document).ready(function () {
    $('#msendsend').click(function () {
        var id=getParam('ID');
        $.ajax({
            type:'POST',
            url:"send.php",

            data:{option:'apply',  sr:$("form").serialize()},
            success:function (jd) {
            }
        });
    });
});
</code></pre>

<p>This is the server code:</p>

<pre><code> if($_REQUEST['option']=='catapply') {
    $sc=$_POST['sr'];
    mysql_query("insert into user_data(uid,data) values('$session-&gt;userid','$sc')");
  }
</code></pre>

<p>And here I am unserializing .</p>

<pre><code> $sql = mysql_query("SELECT * from user_data");
        while ($row = mysql_fetch_array($sql)) {
            $un = unserialize($row['data']);

            $city=$un['city'];
            echo $city;
        }
</code></pre>

<p>The data in the database is shown as</p>

<pre><code>to=&amp;select_category=25&amp;msg=&amp;city=laho
</code></pre>
