18 replies
Hi all

Im haveing a issue here with this script adding peps to the datadatabase not sure why it dont

This is the config file for it

PHP Code:
  //----------- added 20.07.2010-----------
function user_add($facebook,$curr_user)
{
  if( !
$facebook )
  {
    return 
"testing...";
  }
  try
  {
    
$q "SELECT uid, first_name, last_name
          FROM user WHERE uid="
.$curr_user;
    
$rs $facebook->api_client->fql_query($q);
    
// Build an delimited list of users...
    
if ( $rs )
    {
      
$count count($rs);
      for( 
$i=0$i $count$i++ )
      {
        
$u_id intval($rs[$i]["uid"]);
        
$f_name trim($rs[$i]["first_name"]);
        
$l_name trim($rs[$i]["last_name"]);
        
$name $f_name." ".$l_name;
        break;
      }
    }
  }
  catch(
Exception $ex)
  {
    echo 
$ex->getMessage();
  }
  if( isset(
$u_id) AND $u_id )
  {
    @
db_execute("INSERT INTO `user` (`id` ,`name` )VALUES (".$u_id.", '".$name."');");
  }
}
function 
user_exists($curr_user)
{
  
$sql "SELECT id FROM `user` WHERE id=$curr_user;";
  
$query = @db_execute($sql);
  if( 
$query )
  return 
mysql_num_rows($query);
}
?> 
and this is the add user file

PHP Code:
  <?php
require_once('facebook-client/facebook.php');
$facebook = new Facebook_new($api_key,$secret);
//echo "currr user: $curr_user<br>";
if( $facebook->get_loggedin_user() )
{
  
$curr_user $facebook->require_login();
  if( !
user_exists($curr_user) )
  {
    @
user_add($facebook,$curr_user);
    
//echo "<br> added new user!";
  
}
  else
  {
    
//echo "<br>user already exists!";
  
}
}
?>

im so lost any help would be great

thanks
#php #urgent
  • Profile picture of the author jwlnewsome
    What exactly are the errors you are getting and i may be able to help.
    {{ DiscussionBoard.errors[2465337].message }}
  • Profile picture of the author Gdubbs316
    thats the problem i get no errors
    {{ DiscussionBoard.errors[2465346].message }}
  • Profile picture of the author jwlnewsome
    it may be that the server has errors switched off
    try this code in the php and see what happens

    error_reporting(E_ALL);
    ini_set('display_errors','On');
    {{ DiscussionBoard.errors[2465386].message }}
  • Profile picture of the author deepakg
    Dear what's the exactly error you find then may be i help help you
    {{ DiscussionBoard.errors[2465396].message }}
  • Profile picture of the author Gdubbs316
    nope errors are on when i get a error it shows up
    {{ DiscussionBoard.errors[2465398].message }}
  • Profile picture of the author Gdubbs316
    it just dont add to the database it will some times for the first couple peps but then stops
    {{ DiscussionBoard.errors[2465404].message }}
  • Profile picture of the author jwlnewsome
    fire accross the facebook class and the db stucture and i will test on my local server to see if i can get to the root of the problem
    {{ DiscussionBoard.errors[2465412].message }}
    • Profile picture of the author Gdubbs316
      i added the files hope you can see the issue
      {{ DiscussionBoard.errors[2465434].message }}
  • Profile picture of the author jwlnewsome
    had a quick look and i'm getting NULL for "$facebook->get_loggedin_user()"

    add thiss code to your php in add_user.php and tell me what you get

    $facebook = new Facebook_new($api_key,$secret);
    var_dump($facebook->get_loggedin_user());
    {{ DiscussionBoard.errors[2465492].message }}
  • Profile picture of the author Gdubbs316
    i get NULL
    {{ DiscussionBoard.errors[2465499].message }}
  • Profile picture of the author jwlnewsome
    theres your problem. the code is doing exactly what you are telling it to do.
    you need to look at that function to see why its returning null
    hope that helped
    {{ DiscussionBoard.errors[2465515].message }}
  • Profile picture of the author Gdubbs316
    im not sure wht you mean bye that
    {{ DiscussionBoard.errors[2465523].message }}
  • Profile picture of the author jwlnewsome
    if the function $facebook->get_loggedin_user() returns null
    then the code below will never run
    {
    $curr_user = $facebook->require_login();
    if( !
    user_exists($curr_user) )
    {
    @
    user_add($facebook,$curr_user);
    //echo "<br> added new user!";
    }
    else
    {
    //echo "<br>user already exists!";
    }

    }

    the if statment is returning false.
    {{ DiscussionBoard.errors[2465587].message }}
  • Profile picture of the author Gdubbs316
    so what can we do
    {{ DiscussionBoard.errors[2465618].message }}
  • Profile picture of the author jwlnewsome
    There is not really a lot i can do from here. All i can suggest is tring to find out why the function is returning null. you will probley need to go back to the API and debug from there.
    sorry i cant help any further but to dig more i would need access to all the code and the server.
    {{ DiscussionBoard.errors[2465654].message }}
  • Profile picture of the author Gdubbs316
    do you have msn can add me on there computerguy54956@hotmail.com i can give excess
    {{ DiscussionBoard.errors[2465668].message }}
  • Profile picture of the author jwlnewsome
    I think you really need to hire some one at this point. As you will appriciate this could take a long time to degug. Maybe check out the warriors for hire for a PHP developer with face book experience. I've never worked with the facebook API so would probably be the wrong person for you.
    sorry i cant help
    {{ DiscussionBoard.errors[2465713].message }}
  • Profile picture of the author weaveronline
    mail me if your issue still exists, i can easily assign a php programmer to you !
    Signature

    Thanks & Regards,
    Reach us at dukeduke600@gmail.com.
    Web Design| Logo Design | Banner Design | Web Development | Mobile Applications [iPhone/iPad/Android/Windows Phone]

    {{ DiscussionBoard.errors[2470930].message }}

Trending Topics