0

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>

Edited by imti321: misspelled

2
Contributors
5
Replies
9
Views
6 Years
Discussion Span
Last Post by hielo
0

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

0

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>
0

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.";
0

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";

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.