I am trying to pass an object into a function. however each time I get the following error:
Fatal error: Call to a member function getSession() on a non-object in /home/content/52/5733352/html/vanstand/laboratory/db_login.php on line 65
Of course, I am not sure why.
Here is the code I wrote that is causing this error:
Code: Select all
define('ID', '***************');
define('KEY', '*********************************************');
define('SEC', '*********************************************');
// new object
$fb=new Facebook(array(
'appId' => ID,
'secret' => SEC,
'cookie' => true, ));
function restrictedtwo($object)
{
//login & logout variables
$login = $object->getLoginUrl(
array('req_perms' => 'email, user_likes, publish_stream, read_friendlists'));
//check to see if if there is a session
if (empty($_SESSION['user_id']))
{
// If no session check to see if user is logged into facebook
if($object->getSession())
{
//if logged in check against database
//facebook email variable to check against db
$fbme = $object->api('/me');
$fbemail = $fbme['email'];
db_connect('jost', 'and', 'borax', '');//to db
//query for user in db
$query = "SELECT user_id, username FROM users WHERE ";
$query.= "email='".$fbemail."' LIMIT 1";
$result = mysql_query($query);
if(!$result)
{
die("Cannot query: <br />".mysql_error());
}
if (!$result_row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$log = "You are not registered";
loginform ($log);
exit;
}
session_start();
$_SESSION['user_id'] = $result_row['user_id'];
$_SESSION['username'] = $result_row['username'];
}else{
$log = '<center><a href="'.$login.'"> <img src="http://static.ak.fbcdn.net/rsrc.php/zB6N8/hash/4li2k73z.gif"></a></center>';
loginform ($log);
exit;
}
}
}