May 9th, 2009, 1:44 PM
Ah! Any time you include() or require() files you need to use server paths, not URLs. If you can't figure out the right absolute path (I've been there!) try a relative one instead - but make sure its relative from the CALLING page, not the file containing the class. If you're calling that class from multiple pages, you'll need to doctor the class like so:
But you'll need to update the relative path in the require_once() call for your setup. What that new code does is always compute the relative path to the api.php file from the file containing the class - not the original file that includes the class file.
Jeez that sounds confusing. Paths are always a nuisance to figure out... maybe the absolute path is the simplest!
- Ben
PHP Code:
<?php
class CandidatesRegistrationController extends Controller {
public function on_start() {
$curr_folder = dirname(__FILE__);
require_once("$curr_folder/../path/to/database/global/api/api.php");
$fields = ft_api_init_form_page("", "test");
$params = array(
"submit_button" => "submit",
"next_page" => "/success.php",
"form_data" => $_POST,
"finalize" => true
);
ft_api_process_form($params);
}
}
?>
But you'll need to update the relative path in the require_once() call for your setup. What that new code does is always compute the relative path to the api.php file from the file containing the class - not the original file that includes the class file.
Jeez that sounds confusing. Paths are always a nuisance to figure out... maybe the absolute path is the simplest!
- Ben