Call to undefined function

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Call to undefined function

Postby zoooomla » 20. March 2008 12:50

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?
zoooomla
 
Posts: 4
Joined: 20. March 2008 12:43

Postby Wiedmann » 20. March 2008 13:29

You access the file "common.php" with "http://localhost/phixin/inc/php/common.php"?
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby zoooomla » 20. March 2008 15:27

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.
zoooomla
 
Posts: 4
Joined: 20. March 2008 12:43

Postby Milligan » 20. March 2008 15:35

Last edited by Milligan on 17. July 2008 05:13, edited 1 time in total.
Milligan
 
Posts: 136
Joined: 03. March 2008 06:23

Postby zoooomla » 20. March 2008 15:39

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.
zoooomla
 
Posts: 4
Joined: 20. March 2008 12:43

Postby Wiedmann » 20. March 2008 15:51

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
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby zoooomla » 20. March 2008 16:08

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 :)
zoooomla
 
Posts: 4
Joined: 20. March 2008 12:43


Return to XAMPP for Windows

Who is online

Users browsing this forum: DarthSidus and 50 guests