Reputation: 251
I uploaded my website on a webserver and now it displays following error:
Fatal error: Call to undefined function getactualeventid()
This function is defined in my file functions.php
and i include it on the top of my index.php
file by following line:
include '.\functions.php';
The file functions.php
is in the same directory as my index.php
. Are there settings on the server that I need to change?
//EDIT
In the beginning I used include 'functions.php';
but only a blank page has been loaded, so I tried it with include '.\functions.php'; and then I got at least a clear error message.
I also tried include_once but it doesn't work. I tested the whole stuff on my localhost by using XAMPP where it runs without any problems.
I still don't know what the problem is.
Upvotes: 0
Views: 159
Reputation: 26066
First, the syntax should be:
include('functions.php');
But I would recommend using include_once
instead of include
to avoid scenarios where your script might inadvertently attempt to load the same file more than once.
include_once('functions.php');
But I would also encourage you to use a base path of some sort to prefix the location of the file so you are not constantly juggling relative locations.
For example, in your main config file, you can define a base path like this:
$BASE_PATH = '/the/path/to/the/codebase/';
Then when you do an include_once
, the syntax would be:
include_once($BASE_PATH . 'functions.php');
The benefit of this is no matter how deeply nested your codebase becomes, you will always be anchored to the value of $BASE_PATH
. And your life will be made tons easier thanks to not having to worry about relative path issues.
Upvotes: 1
Reputation: 2366
Use include 'functions.php'
as your functions.php
is on the same directory level where your index.php
is , use include '../functions.php'
if it is one level before index.php
. Hope this helps.
Upvotes: 0