[Solved] PHP includes not working in PHP page

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

[Solved] PHP includes not working in PHP page

Postby Artistmode » 28. April 2012 00:59

Hello all,

I must be doing something stupid due to the lack of support on this issue.
Simply put my includes do not work I have a file called "index.php" and in that file is an include directed to "menu.php". menu.php has a basic structure.

<?php
include ("menu.php");
?>

No joy. Ive tried it six ways from Sunday and still no joy. menu.php will parse by its self but it will not include in the original index.php file.

Again im sure its a novice mistake. Please assist.
Last edited by Artistmode on 30. April 2012 23:27, edited 2 times in total.
Artistmode
 
Posts: 4
Joined: 28. April 2012 00:37
Operating System: Windows 7

Re: PHP includes not working in PHP page

Postby JJ_Tagy » 28. April 2012 06:29

Are index.php and menu.php in the same location?

Try include 'menu.php';
JJ_Tagy
 
Posts: 788
Joined: 30. January 2012 13:44
XAMPP version: 5.5.15
Operating System: Windows 10 Pro x64

Re: PHP includes not working in PHP page

Postby Altrea » 28. April 2012 10:05

Hi Artistmode,

Artistmode wrote:No joy.

What does that mean? What is happening if you request your index.php file with your browser?
And what URL does your browser address bar show if you request the index.php 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: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: PHP includes not working in PHP page

Postby Artistmode » 30. April 2012 18:54

JJ_Tagy wrote:Are index.php and menu.php in the same location?

Try include 'menu.php';


Yes. Same location.

file:///C:/xampp/htdocs/artistmode/index.php

file:///C:/xampp/htdocs/artistmode/menu.php

tried
<?php include("c:/xampp/htdocs/artistmode/menu.php"); ?>

and
<?php include("menu.php"); ?>
Artistmode
 
Posts: 4
Joined: 28. April 2012 00:37
Operating System: Windows 7

Re: PHP includes not working in PHP page

Postby Artistmode » 30. April 2012 18:56

Altrea wrote:Hi Artistmode,

Artistmode wrote:No joy.

What does that mean? What is happening if you request your index.php file with your browser?
And what URL does your browser address bar show if you request the index.php file?

best wishes,
Altrea


Thanks Altrea. Nothing happens(no errors) the menu include just doesn't display in the index.php in the browser.
the menu.php will display the menu items when I directly open the file from htdocs.

file:///C:/xampp/htdocs/artistmode/index.php

file:///C:/xampp/htdocs/artistmode/menu.php

tried
<?php include("c:/xampp/htdocs/artistmode/menu.php"); ?>

and
<?php include("menu.php"); ?>
Artistmode
 
Posts: 4
Joined: 28. April 2012 00:37
Operating System: Windows 7

Re: PHP includes not working in PHP page

Postby Altrea » 30. April 2012 19:38

You made just one big mistake.

file:/// means your browser opens a file directly by filesystem. No webserver will be involved, means no PHP parser will be involved means no php will be parsed.

If you want to request C:/xampp/htdocs/artistmode/index.php, the correct URL will be http://localhost/artistmode/index.php
because http://localhost/ is pointing to C:\xampp\htdocs\.

Every request must begin with http:// or any other webserver protocol on which your webserver is reacting.

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: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: PHP includes not working in PHP page

Postby Artistmode » 30. April 2012 22:17

Altrea wrote:You made just one big mistake.

file:/// means your browser opens a file directly by filesystem. No webserver will be involved, means no PHP parser will be involved means no php will be parsed.

If you want to request C:/xampp/htdocs/artistmode/index.php, the correct URL will be http://localhost/artistmode/index.php
because http://localhost/ is pointing to C:\xampp\htdocs\.

Every request must begin with http:// or any other webserver protocol on which your webserver is reacting.

best wishes,
Altrea


Thank you Altrea. I forgot that, very important part. I was using xamp and I was accessing http://localhost/artistmode/index.php then I stopped using XAMP to learn Javascript and forgot what I was doing. I am off and running. Thank you.
(Kicks self hard)
Artistmode
 
Posts: 4
Joined: 28. April 2012 00:37
Operating System: Windows 7


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 118 guests