I need some PHP help

Status
Not open for further replies.
W

WorldWarIII

Guest
I am trying to get some php put into my page. By using include to have content from another file be loaded... This way I can have the same content on multiple pages by just editing one thing and not using SQL. :)

PHP:
<?php
include("latestupdatehacks.html");
?>

When I place it, nothing is displayed. Also, I am trying to place this within a HTML page. I know I have the naming right. Any suggestions?
 

n00b

Full Member
/?> maybe? Just a suggestion since most html codes end with the same thing with / and such.
 

Renegade89

New Member
I am trying to get some php put into my page. By using include to have content from another file be loaded... This way I can have the same content on multiple pages by just editing one thing and not using SQL. :)

PHP:
<?php
include("latestupdatehacks.html");
?>

When I place it, nothing is displayed. Also, I am trying to place this within a HTML page. I know I have the naming right. Any suggestions?

The file your trying to include needs to be latestupdatehacks.php

PHP Includes don't work for .htm/.html files they have to be .php format AND online they won't display on your computer.

/?> maybe? Just a suggestion since most html codes end with the same thing with / and such.

/'s indicate the end of a tag/code.

.Renegade
 
W

WorldWarIII

Guest
Let me test that, thanks :)

I know they wont display on my computer :D

I tried that and it didn't really seem to work... I'm trying to put it into the HTML of the site so I don't have to convert it all. That way I can edit just the one file. But I have this in the hackupdates.php
HTML:
<li>CS:S - Epic Xtreme v1c<span class="winli"></span> (6.19.07)</li>
<li>CS:S - Epic Xtreme v1b<span class="winli"></span>6 (6.18.07)</li>
<li>CS 1.6 - Epic CS v0.3<span class="loseli"></span> (6.6.07)</li>

And this in the area of my code

PHP:
		<ul>
<?php
include("hackupdates.php");
?>
	</ul>
 

Renegade89

New Member
Umm.. the easy way to use php includes is to change every .html page extension to .php then insert the include code its the only way too really. :p
If you change the extension of every page to .php the html coding inside is still read as html therefore I don't really know whats wrong. :S

.Renegade
 

Renegade89

New Member
Umm.. the easy way to use php includes is to change every .html page extension to .php then insert the include code its the only way too really. :p
If you change the extension of every page to .php the html coding inside is still read as html therefore I don't really know whats wrong. :S

Perhaps it isn't working because:
PHP:
		<ul>
<?php
include("hackupdates.php");
?>
	</ul>
That file where this code belongs is .html instead of .php ?

.Renegade
 
W

WorldWarIII

Guest
I got it fixed buddy, thanks anyways, I talked to my buddy in class.
 

Krzywy

Moderator
make sure that u will restrict what files should be included bcs RFI on that will be very easy :)

RFI == Remote File Include
 
D

Deleted member 78

Guest
I don't see any insult here, he's right, it is hilarious.
But look at me :p:p
 

Auraiken

New Member
Actually the easiest way to make html files be able to be included and 'parsed' with php would be to open your httpd.conf file (if you own/have access to the server) and find:

AddType application/x-httpd-php

It will be a line that looks like this

AddType application/x-httpd-php .phtml .php3 .php

Now we will include html files by changing that line to

AddType application/x-httpd-php .phtml .php3 .php .htm .html

That way you can now include php in any html files. Do the same if you want to run php in other file types.

However, if you do not have access to the httpd.conf file you will have to change all the .html/.htm files you want parsed into .php files.

You should just do this to all your files if you have the ability to run PHP scripts as the files will send html with it anyways. Just remember that PHP goes inside the <?php ?> tags and html should go on the outside.

[ In-Depth Tip ]

Unless of course you are using php to write the html via echo/print/printf functions. Normally you would keep html outside of php scripts unless the php script was used to make constructs like linking texts together

ie. echo "Hey " . "there!"
becomes "Hey there!"

By keeping plain text outside of echo/print/printf functions you would be saving time loading by making sure the php doesn't parse through the useless text.
 

FSOwner

FS Owner
by doing AddType application/x-httpd-php .phtml .php3 .php .htm .html

thats making PHP parse an HTMl page as well. a waste and can cause many problems
 

Auraiken

New Member
Shouldn't be any worse than switching every file to php which would also make php parse through the crap as well.
 
Status
Not open for further replies.
Top