Jump to content

Very Very Simple Problem


Leng

Recommended Posts

This is my website:

 

www.wearenip.com/home.html

 

This is the menu that should appear on the left hand side, but doesn't:

 

www.wearenip.com/menu.php

 

This is my server's output saying that php is running just fine:

 

http://wearenip.com/phpinfo.php

 

I'm using this code in the left side bar div:

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

 

The PHP file will not display from the HTML file no matter what I do.  I've tried using every possible combination of file linking including /menu.php  ./menu.php and even the full http://www.wearenip.com/menu.php etc etc etc

 

I'm genuinely upset about this.  Any help would be greatly appreciated.

 

PS:  I can't get any PHP file to properly include in any HTML file on any computer I have.  Nothing displays whatsoever regardless of what is in the PHP file, even if it's just a text word.  Doesn't matter if it's hosted on a PHP compatible internet server or just on a local server or just on the local machine itself.  Nothing.

Link to comment
https://forums.phpfreaks.com/topic/214479-very-very-simple-problem/
Share on other sites

I've tried renaming the file home.php, I've tried making a NEW php file from scratch, making a NEW php file from DreamWeaver, I've tried everything on multiple computers and multiple servers and different kinds (Apache, etc) and can not get a single instance of

 

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

 

to work at all, period.  Has anyone else ever got this to work?  Every single website says this is all you have to do is include this one line of code in your HTML.  I've tried using 'menu.php', "www.wearenip.com/menu.php", 'www.wearenip.com/menu.php', literally HUNDREDS of combinations of computers, servers, browsers, etc.

 

I'm banging my head against the wall.  I can't get a single PHP script to run, even if it's as simple as ECHO'ing hello world.

Look, all you have to do is go to:

 

www.wearenip.com/home.html

 

and click on "View page source" in your browser.  Look and see it even pinks out the one PHP line of code:

 

examplea.jpg

 

wtf?  That should have my menu in HTML form, not a pinked-out or greyed-out PHP code.

Because any php code in an html file will not be interpreted/parsed unless the file has a .php extension, or the .html file extension has been added to the types of files that the php interpreter should parse.

But I've changed the names of all the files to end in .php instead of .html and the exact same thing happened, even when I refreshed the entire server and reloaded all the files (so they're only php) and refreshed on multiple browsers.

 

(D'oh, changing to php works when I allow the server to actually update.)

That's exactly what I'm saying.  PHP should replace that line with the menu.php file located here:

 

www.wearenip.com/menu.php

 

Why is that not happening?  Thank you for your help.

 

PHP should not replace that line with anything unless it is contained within a file that the PHP interpreter has been specifically instructed to parse, such as those with a .php file extension. That file currently has a .html extension, thus it is being ignored.

 

EDIT: Create a copy of the home.html file, and save the copy with a .php extension.

Whoops, sorry coupe-r!  Your solution was also correct, the only reason it didn't work when I tried it is because I didn't properly refresh the server.  *blushes*  Thanks a ton for helping me out.

 

I really thought this server's PHP was configured to parse HTML files

 

You guys rock!  :)

You're welcome. You don't need to have anything reconfigured if you don't want to. You can simply save any file with PHP code in it with a .php extension, and it will be fine. Just remember to edit any references (such as include()s ) to reflect the .php extension.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.