what's wrong with my require_once path?
You use require_once and have error "Class 'Facebook' not found". If you tried require_once on a file that does not exist, it would cause other error: "Fatal error: require(): Failed opening required 'php-sdk/facebook.php'". So the path is probably OK. Check if you uploaded php-sdk properly. The facebook.php might be empty.
Your error is :
Fatal error</b>: Class 'Facebook' not found in <b>/home/zjkkvcxc/public_html/accepted.php</b> on line <b>9
The valuable information here is :
- the error occurred because the
Facebook
class is unknown which means thatrequire_once
did not pop this error - the error occurred on line 9 of accepted.php
Now you have to look why the class Facebook
is unknown on line 9.
- if you have included the
facebook.php
before line 9 it is probably not containing the right class. (class names are case sensitive!) - if you include
facebook.php
after line 9 you just have to call it earlier.
PS: posting the first 10-15 lines of accepted.php
might give us enough information to pinpoint the exact problem here.
I have faced issues like this before, and the best way to handle this is to set your true filepath as a variable & prepend that to your includes/requires. Becuase the whole dirname(__FILE__)
setup can act oddly in different environments especially those that use symbolic links. Explicitly stating where files are to be set is the best solution.
So let’s assume this is your codebase path; as per your example:
/home/zjkkvcxc/public_html/
Set that as a variable that all of your pages load in some way like this:
$BASE_PATH = '/home/zjkkvcxc/public_html/';
And now when you make calls to the file system for your app, do this:
require_once($BASE_PATH . 'php-sdk/facebook.php');
What is nice about a setup like this is that you can make your app portable between environments by just changing $BASE_PATH
to match your local environment. Like this might be a path for a MAMP (Mac OS X LAMP) setup:
$BASE_PATH = '/Application/MAMP/htdocs/';
Regarding how odd __FILE__
can act in symlinked environments, read up here:
Since PHP 4.0.2, _ FILE _ always contains an absolute path with symlinks resolved whereas in older versions it contained relative path under some circumstances.