Weird error with specific file name

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

Weird error with specific file name

Postby danghm » 28. March 2013 08:16

I'm currently using XAMPP lite 1.7
Below is my test project

db.php
Code: Select all
<?php
function greeting() {
    echo "Ciao";
}

inc.php
Code: Select all
<?php
require 'db.php';

index.php
Code: Select all
<?php
require 'inc.php';

admin/index.php
Code: Select all
<?php
require '../inc.php';


Everything seems fine. The code run well on http://localhost/test/index.php, the greeting is echoed.
But when browsing to http://localhost/test/admin/index.php, XAMPP returns a fatal error:

Fatal error: Call to undefined function greeting() in D:\xampp\htdocs\test\admin\index.php on line 5


This error not orcur when I rename db.php to functions.php

How to fix that?
danghm
 
Posts: 2
Joined: 28. March 2013 08:05
Operating System: Windows 7 Pro x64

Re: Weird error with specific file name

Postby Altrea » 28. March 2013 09:58

Hi danghm,

Please start new threads with the words "Hi" or "Hello". A short salutation is an act of politeness. Even if the internet is an virtual area, there is always a human being behind the screen. A polite beginning is the first positive impression you can leave here and helps to get polite answers too. Please keep that in mind if you start a new thread in any community board. Thank you.

danghm wrote:
Fatal error: Call to undefined function greeting() in D:\xampp\htdocs\test\admin\index.php on line 5


This error not orcur when I rename db.php to functions.php

How to fix that?

This occurs because PEAR also has a db.php file which will get loaded with your require function instead of yours.
If you don't use PEAR you can easily remove the PEAR path from the include_path setting in your php.ini file.

best wishes,
Altrea
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Weird error with specific file name

Postby danghm » 28. March 2013 15:31

Hi Altrea,

Thanks for the answer and please excuse my bad behave. English is not my main language and I am very bad at it. I will keep your advice in mind. Again, thank you very much for your support.
danghm
 
Posts: 2
Joined: 28. March 2013 08:05
Operating System: Windows 7 Pro x64

Re: Weird error with specific file name

Postby Altrea » 28. March 2013 16:21

You're welcome :)
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 116 guests