PDA

View Full Version : How Can I Get This Script To Work?


John_Saunders
01-11-2003, 03:18 AM
I came across a cool script at http://martin.f2o.org/download/sitemap/ for creating a navigation bar and sitemap. I uploaded it to my server and installed the DB and PEAR files from the PEAR website and I keep getting the error below when trying to calll www.domain.com/global.php.

Fatal error: Call to undefined function: connect_db() in /home/website/public_html/global.php on line 36

I don't understand why it isn't connecting and I don't see any place in the script that includes the config.php file. I tried copying and pasting the entire config.php script into the globabl.php but it still didn't work. I know my settings are all correct for the database connection and the path to the DB.php is correct:

function &db_connect() {
require_once '/home/website/public_html/php/pear/DB.php';

$db_host = 'localhost';
$db_user = 'template';
$db_pass = 'test1234';
$db_name = 'template';

$dsn = "mysql://$db_user:$db_pass@$db_host/$db_name";

$db = DB::connect($dsn);

if (DB::isError($db)) {
die ($db->getMessage());
}
$db->setFetchMode(DB_FETCHMODE_OBJECT);
return $db;
}


Can somebody tell me why it isn't working? They didn't have an example of how to call a page or anything in the sitemap.zip download.


John

mordred
01-11-2003, 09:06 AM
I have no experience regarding this script, but a quick look in the global.php page showed me no trace of a connect_db() function call - is your error description above correct?

If that helps, the config.php file is included on line 7:


require_once '../config.php';


You may have to adjust this path.

Generally, it's always better to ask the author of a particular script in case of any shortcomings or malfunction. Perhaps you did that already and received no response, but better tell us so.

Spookster
01-11-2003, 09:31 AM
You are getting that error because you have a function named db_connect() not connect_db()

John_Saunders
01-11-2003, 02:41 PM
Thanks Guys for your help. I renamed the section where it called the function to connect to the database to db_connect() and now I'm getting the error: DB Error: connect failed.

I also searched all three files (unchanged copies) for config.php and nothing came up so I just inserted the line above to require the file.

Maybe I didn't install the PEAR and DB files correctly??? I uploaded them to /home/website/public_html/php/pear/ and all the paths are correct in the DB.php and PEAR.php. When I downloaded the two gzip files from the Pear website I just uploaded all of the contents after unzipping them to the php directory. I also ran the Install.php script. Did I not do something right?

I will get in touch with the creator of the script and see if he can give me some advice. If someone knows what I'm doing wrong or can get the script to work, please let me know.


John

mordred
01-12-2003, 08:33 AM
If you get the PEAR-DB error, then is PEAR correctly installed. Double-check your paths again and the database info, maybe the error lies there.