Page 1 of 1

Call to undefined function

PostPosted: 20. March 2008 12:50
by zoooomla
Hi, I'm having a problem running a php script with XAMPP. It works perfectly on any host I've ever used, but XAMPP just doesn't want to run it.

Error:
Code: Select all
Fatal error: Call to undefined function get_config() in C:\xampp\htdocs\phixin\inc\php\common.php on line 16


General location of the error being found:
Code: Select all
   include 'config.php';
   $config = get_config();
   
   function microtime_float() {
      list($usec, $sec) = explode(' ', microtime());
      return ((float)$usec + (float)$sec);
   }

Function get_config() is inside config.php in the same folder.

Heres the contents of config.php:
Code: Select all
<?php

function get_config() {
   return array(
      'db-host' => 'localhost',
      'db-user' => 'root',
      'db-pass' => '',
      'db-table' => 'grabit'
   );
}



Can anyone tell me what I'm doing wrong?

PostPosted: 20. March 2008 13:29
by Wiedmann
You access the file "common.php" with "http://localhost/phixin/inc/php/common.php"?

PostPosted: 20. March 2008 15:27
by zoooomla
The file I accessed was 'index.php' which includes a file 'common.php'. 'common.php' includes the file 'config.php' which holds the function that is not working. Everything is the same as it is on my hosting and my hosting works just fine.

PostPosted: 20. March 2008 15:35
by Milligan

PostPosted: 20. March 2008 15:39
by zoooomla
Assuming that is the case, yes I am able to access it. However it just shows as being blank which is probably right anyway since it only contains a set of functions.

PostPosted: 20. March 2008 15:51
by Wiedmann
The file I accessed was 'index.php' which includes a file 'common.php'. 'common.php' includes the file 'config.php' which holds the function that is not working.

Well, e.g.:

a) if you access the the file 'index.php' in the directory "C:\xampp\htdocs\" with "http://localhost/index.php"

b) and the file "index.php" includes a file "common.php" in the directory "C:\xampp\htdocs\phixin\inc\php\" with "include 'phixin/inc/php/common.php';"

c) the file "common.php" can't include a file "config.php" in the directory "C:\xampp\htdocs\phixin\inc\php\" with "include 'config.php';".

The "common.php" must also use "include 'phixin/inc/php/config.php';" or you must setup a include_path. (Maybe you have not correct configured the script "phixin"?)
--> http://de.php.net/manual/en/function.include.php

PostPosted: 20. March 2008 16:08
by zoooomla
Why does it work in 1 place and not another? The only difference I can think of is PHP version or something server side. The script is already running online with the code as-is. How would I go about making it work as-is instead of changing the included location?

EDIT: Thank you for helping me get it working at the very least :) Now I'm able to work on my little project :)