EVERYTHING IS OK DONT KNOW WHY IT DOSENT WORK I THINK THERE IS PROBLEM IN 'PATH' IT SHOWS ERROR ON LINE 27 NEAR </td>

<html>
<table width='70%' align='center'>
<tr>
<td>
<img src='inc/b.png'>
</td>
</tr>
</table>
<table width='20%' align='center'>
<tr>
<td>
<a href='index.php'>Home</a><br>
<a href='index.php?page=tutorials'>Tutorials</a>
</td>
<td width='80%'>
<?php
$page=$_GET['page'];
if ($page)
{
$path = "inc/".$page.".php";
if (file_exists($path))
{
include($path);
}
else
(
echo"Page doesnt exist."	
)
</td>
</tr>
</table>
</html>

Recommended Answers

All 5 Replies

line 27 is missing a semicolon at the end: echo"Page doesnt exist.";

line 27 is missing a semicolon at the end: echo"Page doesnt exist.";

i have soloved that one i had placed index file in same folder as other folders when i got index file out everything got ok now i have a problem when i click home button it displaces this error

Notice: Undefined index: page in C:\wamp\www\webdesigning1\webdesigning1\inc\index.php on line 28
Page doesnt exist.

it does not recognise the file "tutorials" in "inc" folder because in first place there is a problem with "$page" in index

thanks
masudi

line 26 should be { line 28 should be } also, you are missing the closing brace } for the first if Try:

<html>
<table width='70%' align='center'>
<tr>
<td>
<img src='inc/b.png'>
</td>
</tr>
</table>
<table width='20%' align='center'>
<tr>
<td>
<a href='index.php'>Home</a><br>
<a href='index.php?page=tutorials'>Tutorials</a>
</td>
<td width='80%'>
<?php
if( isset($_GET['page']) && !empty($_GET['page']) )
{
	$page=$_GET['page'];
	$path = "inc/".$page.".php";
	if (file_exists($path))
	{
		include($path);
	}
	else
	{//<-- should NOT be parenthesis
		echo"Page doesn't exist.";
	}//<-- should NOT be parenthesis
}//<-- you are missing this
?>
</td>
</tr>
</table>
</html>

i had tried that one before by pasting your code from

#
<?php
#
if( isset($_GET['page']) && !empty($_GET['page']) )
#
{
#
$page=$_GET['page'];
#
$path = "inc/".$page.".php";
#
if (file_exists($path))
#
{
#
include($path);
#
}
#
else
#
{//<-- should NOT be parenthesis
#
echo"Page doesn't exist.";
#
}//<-- should NOT be parenthesis
#
}//<-- you are missing this
#
?>

only the message is not displayed it still does not recognise this command line and instead jumps to

echo"Page doesn't exist.";

based on this:

Notice: Undefined index: page in C:\wamp\www\webdesigning1\webdesigning1\inc\index.php on line 28

my guess is that you have the post above in:
C:\wamp\www\webdesigning1\webdesigning1\inc\index.php

But it should be in:
C:\wamp\www\webdesigning1\webdesigning1\index.php

OR if you want to retain that code in:
C:\wamp\www\webdesigning1\webdesigning1\inc\index.php

then change $path = "inc/".$page.".php"; to $path = $page.".php";

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.