PHP help urgent

by 18 replies
20
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
#programming #php #urgent
  • What exactly are the errors you are getting and i may be able to help.
  • thats the problem i get no errors
  • 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');
  • Dear what's the exactly error you find then may be i help help you
  • nope errors are on when i get a error it shows up
  • it just dont add to the database it will some times for the first couple peps but then stops
  • 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
    • [1] reply
    • i added the files hope you can see the issue
  • 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());
  • i get
  • 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
  • im not sure wht you mean bye that
  • if the function

    the if statment is returning false.
  • so what can we do
  • 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.
  • do you have msn can add me on there computerguy54956@hotmail.com i can give excess
  • 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
  • mail me if your issue still exists, i can easily assign a php programmer to you !

Next Topics on Trending Feed