Jump to content

PHP Syntax Error


jrapin

Recommended Posts

PHP People,

I am attempting to correct a syntax error in a PHP file.
The file uses the require once command. I need to indicate the correct directory for a file that will be uploaded to a FTP server.

Could you help me determine the correct syntax for the DB.php file? Since it is only on the C-Drive, and the file is requiring it once, does it have to be uploaded to the FTP space would a correction in the directory be sufficent?

I know a correction in the directory is necessary because AI have received this error message "Fatal error: Failed opening required 'DB.php' (include_path='C:/php/pear') in /home/webadmin/jupiter.com/html/calendar/cal_inc.php on line 4?

Respectfully,

Jesse R.

the Cal_inc.php file looks like this:
<?php
function connect() {
ini_set("include_path", "C:\php\pear");
require_once("DB.php");
$type = "mysql";
$username = "caladmin";
$password = "caladmin";
$host = "localhost";
$database = "event_calendar";
$dsn = $type . "://" . $username . ":" . $password . "@" . $host . "/" . $database;
$dbconn = DB::connect($dsn);
errortrap($dbconn);
$dbconn->setFetchMode(DB_FETCHMODE_ASSOC);
return $dbconn;
}//end connect
Link to comment
https://forums.phpfreaks.com/topic/26720-php-syntax-error/
Share on other sites

Yes, you need to put the file somewhere that the web server has access to it. And the command require_once does not mean that it is ONLY accessed once. Every time the page is called it will need to access that required file. The require_once is used in case your code *may* attmept to call the file multiple times in one call. If the included page has functions it would throw an error if called twice.
Link to comment
https://forums.phpfreaks.com/topic/26720-php-syntax-error/#findComment-122228
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.