PDA

View Full Version : PHP: Which Code Is Right???


Kevinnaia
02-18-2003, 12:57 PM
Which code is right?

<?php include ("ID"); ?>
<?include ("ID"); ?>
<?php include ("ID");?>
<?include ("ID");?>

or are they all wrong? people have said that <?include ("ID"); ?> was right but it doesn't work on my site! and when you link to a file, would it be like:

<a href="index.php?ID=home.html" target="_PARENT" name="Home" onmouseover="window.status='Home'; return true;" onmouseout="window.status=''; return true;" title="Home" accesskey="H">Home</a>

Thank You,
Kevin Naia

<htmlite>
02-18-2003, 03:42 PM
The PHP include might only work with actual files.

Example, here is one of my includes...

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

That finds the file and puts the coding contents of the file into that spot.

transmothra
02-18-2003, 04:03 PM
depends on how your PHP is set up. most of the time, using "<?" is fine; you probably don't have to actually put the "php" bit in there.

<?
if (isset($ID)) {
include("$ID");
} else {
include("something.php");
}
?><a href="?ID=home.html">Home</a>

should work.

transmothra
02-18-2003, 04:06 PM
the reason it wasn't working was probably because you didn't have "ID" as a variable. in other words, you didn't have the "$" in front of its name, e.g., "$ID".

Kevinnaia
02-18-2003, 05:26 PM
Thank You!