Why won't this work???

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kydude1957
Forum Commoner
Posts: 31
Joined: Sun Sep 14, 2014 1:37 am

Why won't this work???

Post by kydude1957 »

I have a problem with running the following script in my index.php on Apache.

Code: Select all

<?php

include("includes/header.php");
include("includes/navbar.php");
include("includes/footer.php");
?>
If I put these back together in one index.php file it displays perfectly. However, if you run it the browser displays the code and thats all.

I have been through all the tweeks for includes according to the apache instructions. I have even tried it on another server that is not WAMP and it does the same thing. Can anyone help me please? Just trying to learn.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Why won't this work???

Post by requinix »

What is the URL in the address bar when you "run it in the browser"? You tried it on another server how, exactly?
kydude1957
Forum Commoner
Posts: 31
Joined: Sun Sep 14, 2014 1:37 am

Re: Why won't this work???

Post by kydude1957 »

file://localhost/C:/wamp/www/MySite/test.php

is what shows up in WAMP. Tried it in EzPHP same thing. Both servers index.php and includes folder are in the root directory.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Why won't this work???

Post by requinix »

Yeah, can't do that.

You must be viewing the script through WAMP and not the filesystem. The URL will look something like

Code: Select all

http://localhost/MySite/test.php
kydude1957
Forum Commoner
Posts: 31
Joined: Sun Sep 14, 2014 1:37 am

Re: Why won't this work???

Post by kydude1957 »

Changed it to this:

Code: Select all

<?php
include("http://localhost/MySite/includes/header.php");
include("http://localhost/MySiteincludes/navbar.php");
include("http://localhost/MySite/includes/home.php");
include("http://localhost/MySite/includes/footer.php");
?>
kydude1957
Forum Commoner
Posts: 31
Joined: Sun Sep 14, 2014 1:37 am

Re: Why won't this work???

Post by kydude1957 »

posted my changed script on the other post.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Why won't this work???

Post by requinix »

Remember a couple posts up when I asked you what the URL in your browser's address bar was? Then you replied? Then I said what you saw was wrong? I was still talking about the URL in your browser's address bar. The conversation did not suddenly revert to your code.

Change the code back to what it was before and point your browser to http://localhost/MySite/test.php.
Post Reply