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 9007149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:36:37+00:00 2026-06-16T01:36:37+00:00

I’ve been working on this for ~2 days now and can’t find a solution

  • 0

I’ve been working on this for ~2 days now and can’t find a solution after checking my code and error logs for hours. So, I’m hoping some fresh eyes will help.

I’m gathering facebook data and inserting it into my database. When I run a var_dump on the $sql INSERT command I see all the facebook data in the string. I’ve also run var_dumps on each variable to make sure the data is there. It is and each show as a string type. This matches what the database is expecting–VARCHAR with plenty of room.

I have a few other tables in this database and they are still accepting data so it doesn’t seem to be a database issue (this is a shared server and I don’t have access to it). Also, I’ve tried what seems like almost every variation of syntax, different quotes, etc. in the INSERT statement, but to no avail….

Finally, the error I get as a result of mysql_error() is “You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘m just a chill dude looking for some fun . . .’,’AAAIAZB21He9sBAOLpbm3XTwabMVX0s’ at line 1”. What you are seeing in the single quotes (‘) is the current data for the $fbabout and $at VALUES in the INSERT statement.

With that, here is the code to the php file. Thank you in advance for taking the time to check this out!

<?php 
require_once("facebook.php");

$app_id = "";
$app_secret = "";
$my_url = "";



$code = $_POST["code"];

if(empty($code)) {
        $dialog_url = "https://www.facebook.com/dialog/oauth?client_id=" 
        . $app_id . "&redirect_uri=" . urlencode($my_url) . "&state="
        . $_SESSION['state']."&scope=email,user_birthday,user_interests,friends_interests,publish_stream,user_about_me,user_checkins";

        echo("<script> top.location.href='" . $dialog_url . "'</script>");



} else {
    $host=""; // Host name 
    $username=""; // Mysql username 
    $password=""; // Mysql password 
    $db_name=""; // Database name 
    $tbl_name=""; // Table name  

    // Connect to server and select database.
    mysql_connect("$host", "$username", "$password")or die("cannot connect");
    mysql_select_db("$db_name")or die("cannot select DB");  

        $token_url = "https://graph.facebook.com/oauth/access_token?"
        . "client_id=" . $app_id . "&redirect_uri=" . urlencode($my_url)
        . "&client_secret=" . $app_secret . "&code=" . $code;

        $response = file_get_contents($token_url);
        $params = null;
        parse_str($response, $params);

        $_SESSION['access_token'] = $params['access_token'];

        $graph_url = "https://graph.facebook.com/me?access_token=". $params['access_token'];
    $interests = "https://graph.facebook.com/me/interests?access_token=". $params['access_token'];

    $user = json_decode(file_get_contents($graph_url));
    $user_interests = json_decode(file_get_contents($interests));

    $id = $user->id;        
    $fname = $user->first_name;
    $lname = $user->last_name;
    $link = $user->link;
    $gender = $user->gender;
    $locale = $user->location->name;
    $email = $user->email;
    $bday = $user->birthday;

    $uidata = array();
    $number = count($user_interests->data);
            for ($i = 0;$i<=$number-1;$i++){
           array_push($uidata,($user_interests->data[$i]->name));
    }
    $ui = implode(",", $uidata);

    $fbabout = $user->bio;
    $at = $params['access_token'];

    // Insert data into mysql 
    $sql="INSERT INTO $tbl_name(fbid,fname,lname,link,gender,locale,email,birthday,interests,fbabout,fbtoken)VALUES('".$id."','".$fname."','".$lname."','".$link."','".$gender."','".$locale."','".$email."','".$bday."','".$ui."','".$fbabout."','".$at."')";
    $result=mysql_query($sql);


    if($result) {
        header( 'Location: https://crushonit.com/join/fbRegister.html' );
    } else {
        echo mysql_error();
    }

} 
?>

<?php 
// close connection 
mysql_close();
?>
  • 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-16T01:36:38+00:00Added an answer on June 16, 2026 at 1:36 am

    As other people have commented, you should always clean any data before inserting it into a database, using mysql_real_escape_string() at the very least. In your case, the “I’m” is causing you problems.

    I have another query though; you are using the PHP SDK, by including facebook.php, but you are also manually querying the graph using file_get_contents. This strikes me as odd, because if you are using the SDK you don’t need to do that. The SDK will create an object and you query that.

    https://developers.facebook.com/docs/reference/php/

    The above link may be of some help.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
This could be a duplicate question, but I have no idea what search terms

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.