Jump to content

Having trouble with include / get statement. Help!


Alex1646
 Share

Recommended Posts

Im  trying to create a php template.

What I want to do is take in GET data saying what page I am on, then include that in the template.

THe trouble is I cant get the damn thing to work, it keeps saying the file does not exist!

Here is my code

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<div class="content">
<?php
$page = $_GET['page'];
$path = '/inc '  .$page .".php";

if(!isset($page))
{
die('No Page Specified');
}

if (file_exists($path))
{
include($path);
}
else 
{
die('Does not exsist!');
}

?>
</div>
</body>
</html>

Link to comment
Share on other sites

On this line:

 

$path = '/inc '  .$page .".php";

 

I notice there is a space after "/inc". Does the file to be included have a space in the file name? Is the file in the root of your application? Try to echo out what the path it's concatenating is and verify that the path is correct. It may be just as simple as that space causing issues.

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • 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.