Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7309169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T00:04:04+00:00 2026-05-29T00:04:04+00:00

Something went wrong with my code. The insert code does not work. Can someone

  • 0

Something went wrong with my code. The insert code does not work. Can someone tell me what went wrong? The code is supposed to insert the person fbid name and email to my database when the users click a button, however nothing appears in my database.

<?php
header('P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"');
include_once 'mysqli.connect.php';
include_once 'fbmain.php';

if($me){
    $fbid= $facebook->api('/me');
    $fbme = $fbid['id'];
    $fbName = $fbid['name'] ;  
    $fbEmail = $fbid['email'];
}
if (isset($_POST['submit']) ){
    mysqli_query("INSERT members SET fbId='$fbme',name='$fbName', email ='$fbEmail'" );
}
?>
<html>
<form action="" method="post">
    <input type="image" src="../images/buy.png" name="submit" width="60"height="30" />
</form>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T00:04:06+00:00Added an answer on May 29, 2026 at 12:04 am

    You should really check for errors to find out what is going on if something doesn’t work (as expected).

    That being said:

    mysqli_query takes 2 required parameter, link and query, but you only supplied the query.

    Another thing: even if you would have done that your query still is invalid. It should be:

    "INSERT INTO members (fbId, name, email) values ('$fbme', '$fbName', '$fbEmail')"
    

    Also note that you check for the variable $me (which as you stated is coming from FaceBook). So my question is what will happen when FB is down or whatever and you try to submit the form? You will still try to run the query even though the required info isn’t there.

    So what I would do is the folllowing:

    $link = mysqli_connect("localhost", "my_user", "my_password", "dbname");
    
    if($me){
        $fbid= $facebook->api('/me');
        $fbme = $fbid['id'];
        $fbName = $fbid['name'] ;  
        $fbEmail = $fbid['email'];
    
        if (isset($_POST['submit'])) {
            mysqli_query($link, "INSERT INTO members (fbId, name, email) values ('$fbme', '$fbName', '$fbEmail')") or die(mysql_error());
        }
    }
    

    As an alternative you could also use prepared statements. One of the benefits of using prepared statements is that it prevents most SQLinjection vulnerabilities. Using prepared statements would look something like this:

    /* Prepare a statement */
    $stmt = mysqli->prepare("INSERT INTO table (col1, col2 ...) VALUES (?, ? ...) WHERE uID=?");
    
    /* Bind parameters */
    $stmt->bind_param('is', $a, $b ...);  // <-- i=int, s=string, etc. etc.
    
    /* Set parameters */    
    $a = $fbMe;
    $b = $fbName;
    ...                // <-- etc. etc.
    
    /* Execute your statement */
    $stmt->execute();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I click a link which calls following function...I get Something went wrong. We're
i have some scripts which give me the alert Something went wrong. I tried
After some time I wanted to update my git repo, and then something went
Something is eluding me ... it seems obvious, but I can't quite figure it
Is there any way to make this piece of code work? The only problem
Can't seem to figure out why this works in Safari but not in chrome.
i have code written something like this. if(!isset($cid)) { echo <script type=\text/javascript\>alert('OOps, Something went
In my helper code I add Ajax link as follows. <%= link_to 'name', events_path(@event),
Something i've never really done before, but what is the best way to make
Something I have always been interested in out of curiosity, is there a tool

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.