Page 1 of 1

[Solved] PHP includes not working in PHP page

PostPosted: 28. April 2012 00:59
by Artistmode
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.

Re: PHP includes not working in PHP page

PostPosted: 28. April 2012 06:29
by JJ_Tagy
Are index.php and menu.php in the same location?

Try include 'menu.php';

Re: PHP includes not working in PHP page

PostPosted: 28. April 2012 10:05
by Altrea
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

Re: PHP includes not working in PHP page

PostPosted: 30. April 2012 18:54
by Artistmode
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"); ?>

Re: PHP includes not working in PHP page

PostPosted: 30. April 2012 18:56
by Artistmode
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"); ?>

Re: PHP includes not working in PHP page

PostPosted: 30. April 2012 19:38
by Altrea
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

Re: PHP includes not working in PHP page

PostPosted: 30. April 2012 22:17
by Artistmode
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)