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

  • Home
  • SEARCH
  • 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 8796043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:31:50+00:00 2026-06-13T23:31:50+00:00

Hey I have a problem… I would like to when a user has shared

  • 0

Hey I have a problem…

I would like to when a user has shared a link from my facebook app, that i get his id into my db.

The way i share the link is via the facebook dialog javascript example that i have modified

The sharing javascript code

<script>
      FB.init({appId: 'xxxx', channelUrl: 'xxxx', status: true, cookie: true});

      function postToFeed() {

        // calling the API ...
        var obj = {
          method: 'feed',
          link: 'https://developers.facebook.com/docs/reference/dialogs/',
          picture: 'http://fbrell.com/f8.jpg',
          name: 'Facebook Dialogs',
          caption: 'Reference Documentation',
          description: 'Using Dialogs to interact with users.'
        };

        function callback(response) {
            xmlhttp=new XMLHttpRequest();
            xmlhttp.onreadystatechange=function(){
                if (xmlhttp.readyState==4 && xmlhttp.status==200){
                    document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
                    document.getElementById('post').style.display = "none";
                }
            }
            xmlhttp.open("POST","shared.php",true);
            xmlhttp.send("id=xxx");
        }

        FB.ui(obj, callback);
      }

</script>

The PHP Code

$con = mysqli_connect("xxxx","xxx","xxx","xxx");
    if (!$con) {
        die('Could not connect: ' . mysql_error());
    };

        mysqli_query($con, "INSERT INTO xxx (fb-id) VALUES (".$_POST['id'].")");

    mysqli_close($con)

When I have shared the link I get the post_id, but the nothing in the db ?

Can anybody tell whats wrong ?

  • 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-06-13T23:31:52+00:00Added an answer on June 13, 2026 at 11:31 pm

    Invalid field name:

    INSERT INTO xxx (fb-id) ...
                     ^^^^^
    

    That looks like two fields being subtracted, not a single field. You’ll probably want to escape it with backticks to force seeing it as a single field name:

    INSERT INTO xxx (`fb-id`) ...
    

    In the greature picture, you’ve got a major gaping SQL injection hole. Stop working on this code and learn about how to avoid this problem before someone destroys your server.

    You’re also assuming the query succeeded, which is a bad thing to do. You’ve got error handling on the connect() call, but nowhere else. NEVER EVER assume a query has succeeded. Always check for errors afterwards.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey I have a function which is called from a html link like this:
Hey I Have some Problem to Find Exact Imotion(Facebook) for That Smily Code.. I
Hey all, i have a problem with trying to get 2 forms to close
Hey guys, I have a weird problem. I have an update system that refreshes
Hey this is the weirdest problem i've ever encoutered, I have 2 projects that's
Hey guys I have a problem with an app I'm making. The thing is
Hey guys, I have a problem with a code that I've been writing. I
Hey all, have a slight problem here. In CakePHP I have a controller that
Hey Guys I have a big problem that I have no Idea why.. I
hey there i am having problem i have List<List<memoryCard>> that i want to show

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.