I want to store my array into my database using jQuery. Here is my code i'm using serialize(); function. Its storing correctly but when i unserialize(); nothing happening. Please help here is my code.
<script>
$(document).ready(function(){
$("#save-skills").click(function(){
var skills = $('input[name="skills[]"]').serialize();
console.log(skills);
$('#loading').css('display', 'block');
var queryString = "skills=" + skills + "";
$.ajax({
url: 'save_skills.php',
cache: false,
contentType: "application/json; charset=utf-8",
dataType:'json',
async: false,
type:'GET',
data: queryString,
success: function(data){
$('#loading').css('display', 'none');
if('error' in data){
$(".re_skills_success").hide(100);
$(".re_skills_err").text(data.error);
$(".re_skills_err").slideDown(400).delay(3000).slideUp(400);
}else if('success' in data){
$(".re_skills_err").hide(100);
$(".re_skills_success").text(data.success);
$(".re_skills_success").slideDown(400).delay(3000).slideUp(400);
}
}
});
});
});
</script>
<!-- Unserialize() code -->
$who = $_COOKIE['Email'];
$skills = @mysql_query("SELECT * FROM `skills` WHERE `who` = '$who'");
$skill_count = @mysql_num_rows($skills);
echo "<h1>Skill count : $skill_count</h1>";
while($sk = @mysql_fetch_array($skills)){
$set_of_skills = "{$sk['set_of_skills']}";
echo "<h1>Array skills : $set_of_skills</h1>";
print_r(unserialize($set_of_skills));
}
this is printing nothing.