0

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.

2
  • 5
    include 'functions.php'; Commented Apr 13, 2014 at 15:07
  • My page is blank, when I try it like that. Commented Apr 13, 2014 at 16:38

5 Answers 5

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

As include is a language construct and not a function, you don't need to include the name of the file that you're including in brackets
0

you can also used require_once(youFileName.php).

Comments

0
include 'functions.php';

And check your functions.

Comments

0

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.

Comments

0

try this

include('functions.php');

1 Comment

hey john iv been sent message about my ans but i dont understand it. is it about length of my ans or the structure?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.