Jump to content
xisto Community
KansukeKojima

I Need Some Proof Reading For My Code Please! [resolved]

Recommended Posts

Well... everything is fine except the Content Select section (refer to the in-code headings)... thats where it says the error is... could anyone find out why it wont work when I click one of my links? http://forums.xisto.com/no_longer_exists/ for an example of what happens...

 

 


if(!isset($page)) {

$content_select = <<< html

<td valign="top" width="750" class="table_class" bgcolor="#ffffff">

$content

</td>

html;

} else {

$content_select = <<< html

There is a content_select error.

html;

}

 

//---------------------------------

//Template

//---------------------------------

 

$template = <<< html

<html>

<head>

<title>

2K ART

</title>

<body marginwidth="0" topmargin="5" rightmargin="5" leftmargin="5" bottommargin="5" bgcolor="#e5e5e5">

<link rel="stylesheet" href="css.css" type="text/css">

 

<table border="0" width="750" cellpadding="0" cellspacing="0" align="center">

<tr>

<td width=750">

<img src="$lay/banner.gif" border="1">

</td>

</tr>

<tr>

<td width="750">

<img src="$lay/nav.gif" border="1">

</td>

</tr>

</table>

<table border="0" width="760" cellpadding="2" cellspacing="4" align="center">

<td valign="top" width="150" class="table_class" bgcolor="#ffffff">

<b>Navigation</b><hr>

$link[1]<br>

$link[2]<br>

$link[3]<br>

$link[4]<br>

$link[5]<br>

</td>

<td valign="top" width="600" class="table_class" bgcolor="#ffffff">

$content_select

</td></tr>

</table>

 

 

<script src="http linenums:0'><?php//-----------------//portfolio paths//-----------------$portfolio = "/portfolio";$lay = "/images";//------------------//navigation//------------------$link[1] = <<< html<b>?</b>?<a href="$PHP_SELF">Home</a><br>html;$link[2] = <<< html<b>?</b>?<a href="$PHP_SELF?cont=portfolio">Portfolio</a><br>html;$link[3] = <<< html<b>?</b>?<a href="$PHP_SELF?cont=programming">Programming</a><br>html;$link[4] = <<< html<b>?</b>?<a href="$PHP_SELF?cont=graphics">Graphics</a><br>html;$link[5] = <<< html<b>?</b>?<a href="$PHP_SELF?cont=misc">Misc.</a><br>html;//----------------------------------// Content Include//----------------------------------$default = "news"; if($cont == "") { $cont = $default; } elseif(isset($cont)) { $cont = $cont; } if(file_exists("$cont.html")) { $content = file_get_contents("$cont.html");} else { $content = "Unfortunately, the file you were looking for could not be located.";}//----------------------------------// Content Select//----------------------------------$page = $_GET['cont'];if(!isset($page)) {$content_select = <<< html<td valign="top" width="750" class="table_class" bgcolor="#ffffff">$content</td>html;} else {$content_select = <<< htmlThere is a content_select error.html;}//---------------------------------//Template//---------------------------------$template = <<< html<html><head><title>2K ART</title><body marginwidth="0" topmargin="5" rightmargin="5" leftmargin="5" bottommargin="5" bgcolor="#e5e5e5"><link rel="stylesheet" href="css.css" type="text/css"><table border="0" width="750" cellpadding="0" cellspacing="0" align="center"><tr><td width=750"><img src="$lay/banner.gif" border="1"></td></tr><tr><td width="750"><img src="$lay/nav.gif" border="1"></td></tr></table><table border="0" width="760" cellpadding="2" cellspacing="4" align="center"><td valign="top" width="150" class="table_class" bgcolor="#ffffff"><b>Navigation</b><hr>$link[1]<br>$link[2]<br>$link[3]<br>$link[4]<br>$link[5]<br></td><td valign="top" width="600" class="table_class" bgcolor="#ffffff">$content_select</td></tr></table><script src="google-analytics.com/urchin.js; type="text/javascript"></script><script type="text/javascript"> _uacct="UA-2884448-1"; urchinTracker();</script> </body></html>html;//----------------------------------// Display the Final Template//----------------------------------echo $template;?>

Share this post


Link to post
Share on other sites

PHP processes its code from top to bottom. You have to place (declare) the cont variable before the "Content Include" section. Try that out.

Share this post


Link to post
Share on other sites

Stepping through the code, I think this line is your problem:

 

if(!isset($page))

If $page is not set then display the content. Otherwise (so if it is set) display an error. I think the code is working perfectly, you've just got the condition the wrong way round :P Take the exclamation mark out from before the isset function and it should work.

Share this post


Link to post
Share on other sites

I removed the !... one problem solved... now, it doesn't show the error... which is a good thing I hope? I think that would mean progress. However, it still doesn't show the page... so the problem must be with the content include area?... http://forums.xisto.com/no_longer_exists/ for the "fixed" version... but yeah... it just keeps showing the news page whenever a link is clicked now... whats the remedy?

Share this post


Link to post
Share on other sites

Well, it is and it isn't the Content Include section.

//----------------------------------// Content Include//----------------------------------$default = "news";if($cont == "") {$cont = $default;}elseif(isset($cont)) {$cont = $cont;}

The first if statement will always return true as you never make $cont equal to anything. I assume you want to pull the variable $cont out of the URL. Therefore, before that section, you need the following line:

$cont = $_GET['cont'];

Share this post


Link to post
Share on other sites

woot!!! yay!!! Thank you!! I had to do one other thing though:I had to remove the $_GET part from the "content select" area... took me a second to find out why the $default page wouldn't show up... :P THANK YOU!!! EVERYTHING IS PERFECT NOW!!!

Edited by KansukeKojima (see edit history)

Share this post


Link to post
Share on other sites

Topic is resolved.Please PM any moderator to continue this discussion. Until then, this topic is closed.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.