Viewed   171 times

I have this testing code in "PAGE A":

<?php
require_once('../mysite/php/classes/eventManager.php');
$x=new EventManager();
$y=$x->loadNumbers();
?>

"eventManager.php" has inside a require_once:

<?php
require_once('../includes/dbconn.inc');
class EventManager {...}
?>

My folders structure is this:

mysite/php/classes folder and includes folder

If i test PAGE A in a browser i receive:

Warning: require_once(../includes/dbconn.inc) [function.require-once]: failed to open stream: No such file or directory in C:wampwwwmysitephpclasseseventManager.php on line 3


Fatal error: require_once() [function.require]: Failed opening required '../includes/dbconn.inc' (include_path='.;C:php5pear') in C:wampwwwmysitephpclasseseventManager.php on line 3

where is the error?

Thanks Luca

 Answers

1

You will need to link to the file relative to the file that includes eventManager.php (Page A)

Change your code from
require_once('../includes/dbconn.inc');

To
require_once('../mysite/php/includes/dbconn.inc');

Friday, September 9, 2022
2

No. Fatal errors are fatal. Even if you were to write your own error handler or use the @ error suppression operator, E_FATAL errors will still cause the script to halt execution.

The only way to handle this is to use function_exists() (and possibly is_callable() for good measure) as in your example above.

It's always a better idea to code defensively around a potential (probable?) error than it is to just let the error happen and deal with it later anyway.

EDIT - php7 has changed this behavior, and undefined functions/methods are catchable exceptions.

Wednesday, November 2, 2022
 
mage_xy
 
4

you do not need to put the full directory to the file. try to remove /public_html/flashsale/ from your link and see if that will work. In addition, the file does not need to have 777 permission, I myself upload files to folders with 755 permissions.

also, you can use getcwd(); in the directory your aiming to. the function will give you the directory that you need to use for moving your file. source

Sunday, December 11, 2022
4

In your Config file or some common file define your path as below

define('DOCROOT', $_SERVER['DOCUMENT_ROOT'].'<YOUR PROJECT DIRECTORY>/');

Include this common php in all your class file.

Then

 $destino= DOCROOT.'Perf_Masc/'.$img; // HERE DOCROOT is defined in config.
Sunday, December 4, 2022
4

According to your question the uploads folder is in /var/www/html, however going by the error message it is trying to upload into /var/www/html/test/uploads which doesn't exist

Either you need to fix the code to upload to the correct path, or you need to create an uploads directory in the test directory

Wednesday, August 24, 2022
 
3

I fixed the problem. Just need to change the name of my class from Mail to MailInterface. Mail class is already taken by something else. I am using XAMPP with PHP 5.5.

Tuesday, December 13, 2022
 
shmidt
 
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :