Click here to Skip to main content
15,889,931 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
My result.php

PHP
<?php

include_once("config.php");

$videoDetailsData = json_decode($_POST['videoDetailsData']);


foreach($videoDetailsData as $videoDetails)
{
$thumbnailImage = mysql_real_escape_string($videoDetails.thumbnailImage);
$title = mysql_real_escape_string($videoDetails.title);
$category = mysql_real_escape_string($videoDetails.category);
$description = mysql_real_escape_string($videoDetails.description);
$videoLink = mysql_real_escape_string($videoDetails.videoLink);

$result = mysql_query("INSERT into videoDetails(thumbnailImage,title,category,description,videoLink)                values('$thumbnailImage','$title','$category','$description','$videoLink')");
}

if($result)
{
echo "success";
}
mysql_close();
?>



My Videoportal.php

PHP
<script>

jQuery(document).ready(function()
{

    jQuery('#submit').click(function()
    {
        var videoDetails =[];
        jQuery('.mycheckbox').each(function()
        {
            if (this.checked == true)
                        {
                var obj = {};

                obj.thumbnailImage =jQuery (this).parent(). find('table').find ('tbody').find('tr').find('td:first').find('img').prop("src");
                obj.title=jQuery(this).parent() .find('table').find('tbody').find('tr') .find('td:nth(1)').find('p:nth(0)').html();
                obj.category=jQuery(this).parent().find('table') .find('tbody').find ('tr').find('td:nth(1)').find('p:nth(1)').html();
                obj.description=jQuery(this). parent().find('table'). find('tbody'). find('tr').find('td:nth(1)').find('p:nth(2)').html();
                obj.videoLink=jQuery(this).parent(). find('table').find('tbody').find ('tr').find('td:nth(1)').find('p:nth(3)').find('a').prop("href");

                videoDetails.push(obj);

                    //alert(videoDetails);
            }
        });
//var jsonString = {array: videoDetails}JSON.stringify(videoDetails);
var jsonString = JSON.stringify(videoDetails);
//alert(jsonString);
        jQuery.ajax(
                {
                type: 'POST',
                url: 'result.php',
                data: JSON.stringify({ 'videoDetailsData': jsonString }),
                success: function(data)
                {
                    if(data=="success")
                    {
                    alert("Data stored successfully");
                    }
                },
                error: function(xhr, textStatus, errorThrown)
                {
                    alert('An error occurred! ' + ( errorThrown ? errorThrown :xhr.status));
                }
                });
//jQuery.post('result.php',{data:jsonString},function(data){alert(data);}{'videoDetailsData': jsonString});

    });

});
</script>

<div id="outputDiv"></div>
<form id="testform" method="POST" action="">
<div>
	<select id="parentCategory" value="parentCategory" name="category">
		<option selected="selected" name="category" value="selected">--Select category--</option>
	</select>
</div>

<div>
	<select id="subCategory" name="subCategory">
		<option selected="selected" name="subCategory" value="selected">--Select subCategory--</option>
	</select><br><br><br>

<div id="results">
</div>
<input type="button" id="submit" value="save"/>
</br></br></br></div>
</form>
</body>
</html>
Posted
Updated 19-Feb-14 18:57pm
v2

1 solution

Your problem is in this part:
PHP
$thumbnailImage = mysql_real_escape_string($videoDetails.thumbnailImage);
$title = mysql_real_escape_string($videoDetails.title);
$category = mysql_real_escape_string($videoDetails.category);
$description = mysql_real_escape_string($videoDetails.description);
$videoLink = mysql_real_escape_string($videoDetails.videoLink);

In PHP . (dot) is used to string concatenation, to access class members you have to use ->!!!
PHP
$thumbnailImage = mysql_real_escape_string($videoDetails->thumbnailImage);
$title = mysql_real_escape_string($videoDetails->title);
$category = mysql_real_escape_string($videoDetails->category);
$description = mysql_real_escape_string($videoDetails->description);
$videoLink = mysql_real_escape_string($videoDetails->videoLink);
 
Share this answer
 
Comments
Janardhanam Julapalli 20-Feb-14 1:59am    
Still not working.The problem is that the data is not coming to result.php through json_decode.
Kornfeld Eliyahu Peter 20-Feb-14 2:18am    
In the first attempt I gave you a wrong advise - it does not work but we do not remove it - do it now...
Change
data: JSON.stringify({ 'videoDetailsData': jsonString }),
to
data: { 'videoDetailsData': jsonString },
Janardhanam Julapalli 20-Feb-14 3:59am    
Got Success.Its working.Thank you very much for your valuable time.If i have any queries in future how can i contact you.
Kornfeld Eliyahu Peter 20-Feb-14 4:02am    
Send it here in QA - you may be lucky and someone more qualified will answer you...
Janardhanam Julapalli 20-Feb-14 4:46am    
Sure sure.Thank You very much.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900