Unable to save more than 2 records

ShivaB

New Member
I am creating a website which will make login from Facebook id and then save the user data to database in php. However My code is working for first 2 records only though each record has been displayed on the screen an array.Here is my code :\[code\] <?php require 'includes/config.php'; require 'includes/facebook.php'; require 'includes/app.php'; require 'includes/dbcon1.php'; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns:fb="https://www.facebook.com/2008/fbml"><head> <title>RM INDIA Quiz</title> <link href="http://stackoverflow.com/questions/12651241/includes/css/frontend_rmindia.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="http://stackoverflow.com/questions/12651241/includes/upload/jquery-1.4.2.min.js"> </script> <script type="text/javascript" src="http://stackoverflow.com/questions/12651241/includes/upload/swfobject.js"></script> <script type="text/javascript" src="http://stackoverflow.com/questions/12651241/includes/upload/jquery.uploadify.v2.1.4.min.js"></script> <script type="text/javascript" src="http://stackoverflow.com/questions/12651241/includes/js/uploadify.js"></script> </head> <body> <div id="fb-root"></div> <div class="main"> <div class="header"> <div class="contents"> <h2>R M INDIA Quiz</h2> </div> <!--contents--> </div> <!--header--> <div class="display"> <div class="contents"> <h2>Please Login / Signup with Facebook to continue...</h2> <p><button id="fb-auth">Login</button></p> <?php require 'includes/js/appjs.php'; if($user){ print_r($userInfo); $userid = $userInfo[id]; $username = $userInfo[name]; $birthday = $userInfo[birthday]; $birthday = date("Y-m-d", strtotime($birthday)); $userlocation = $userInfo[location][name]; $gender = $userInfo[gender]; $useremail = $userInfo; $sql = "INSERT INTO users (userid, username, useremail, birthday, location, gender) VALUES ('$userid', '$username', '$useremail', '$birthday', '$userlocation', '$gender')"; if($result = mysql_query($sql)) { echo "success"; } } ?> </div> </div> <!--display--> <p id="user-info"></p> </div> <!--main--> </body> </html>\[/code\]My script is :\[code\]window.fbAsyncInit = function() { FB.init({ appId: '<?=APPID?>', status: true, cookie: true, xfbml: true, oauth: true }); function updateButton(response) { var button = document.getElementById('fb-auth'); if (response.authResponse) { //user is already logged in and connected var userInfo = document.getElementById('user-info'); FB.api('/me', function(response) { userInfo.innerHTML = '<img src="https://graph.facebook.com/'+response.id+'/picture">'+response.name; button.innerHTML = 'Logout'; }); button.onclick = function() { FB.logout(function(response) { var userInfo = document.getElementById('user-info'); userInfo.innerHTML=""; window.location = 'logout.php'; }); }; } else { //user is not connected to your app or logged out button.innerHTML = 'Login'; button.onclick = function() { FB.login(function(response) { if (response.authResponse) { FB.api('/me', function(response) { window.location.reload(); }); } else { //user cancelled login or did not grant authorization } }, {scope:'email,user_birthday,status_update,publish_stream,user_about_me,photo_upload,user_photos,user_photo_video_tags'}); } } } // run once with current status and whenever the status changes FB.getLoginStatus(updateButton); FB.Event.subscribe('auth.statusChange', updateButton);};\[/code\]
 
Top