User not logged in - login - register
Home Calendar Books School Tool Photo Gallery Message Boards Users Statistics Advertise Site Info
go to bottom | |
 Message Boards » » PHP problem...what am i doing wrong? Page [1]  
quagmire02
All American
44225 Posts
user info
edit post

followed this brief tutorial to set up a PHP-based menu system:

http://www.netcode.net/tutorials/php_mysql/easy_navigation.php

this is the finished product from the guy who wrote the tutorial:

http://www.netcode.net/tutorials/php_mysql/examples/ex3/index.php

this is the same site, on a different server i have access to...i copied and pasted directly from the tutorial, but the actual content isn't showing...what am i doing wrong?

http://www.paneranc.com/phptest/index.php

7/24/2006 9:43:30 PM

Noen
All American
31346 Posts
user info
edit post

do you have register globals turned on?

Did you insert the code?

Did you check the error log for apache, or just turn on error reporting for the page?

There could be a thousand things wrong

7/24/2006 9:50:43 PM

mytwocents
All American
20654 Posts
user info
edit post

you're missing the h2 and h1 items completely from your page

7/24/2006 9:57:46 PM

quagmire02
All American
44225 Posts
user info
edit post

^^ my other php apps work, so if you're talking about server settings, i imagine they're good

registering globals...?

insert what code? my pages look, verbatim, like the code on the tutorial

i have checked no error log

^

[Edited on July 24, 2006 at 10:05 PM. Reason : .]

7/24/2006 10:05:29 PM

Noen
All American
31346 Posts
user info
edit post

post the pages with .phps extensions so we can see the source code, then i can tell you what you fugged up

7/24/2006 10:15:40 PM

quagmire02
All American
44225 Posts
user info
edit post

index.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>My Website</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<body>
<div style="height:50px;border:1px solid #000;margin-bottom:10px">

</div>

<div style="float:left;width:15%;border:1px solid #000">
<ul style="margin-left:10px;list-style-type:none">
<li><a href="index.php">Home</a></li>
<li><a href="index.php?page=about">About</a></li>
<li><a href="index.php?page=contact">Contact</a></li>
</ul>
</div>

<div style="float:right;width:80%;border:1px solid #000">
<div style="padding:4px">
<!-- content here -->
</div>
</div>
</body>
</html>



home.php

<h2>News Item 1</h2>
<p>This is my home page, news and stuff will go here.</p>

<h2>News Item 2</h2>
<p>More news and stuff will go here.</p>



about.php

<p>This is my about page, it's about me.</p>



contact.php

<p>This is my contact page, for contacting me.</p>



all four files are in the same folder called "phptest"

7/24/2006 10:28:21 PM

bous
All American
11215 Posts
user info
edit post

$page isn't handled in any of your php files

7/24/2006 10:30:38 PM

Noen
All American
31346 Posts
user info
edit post

my first post:

Did you insert the code?

And the answer is no. Did you even bother looking at the page? Like the entire second half of the page you linked to with the tutorial? Like the instructions telling you to insert the code he posts?

Wow.

7/24/2006 10:35:51 PM

quagmire02
All American
44225 Posts
user info
edit post

DAMMIT, yes, the code is inserted...i pulled the code from the wrong file...index.php looks like:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>My Website</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<body>
<div style="height:50px;border:1px solid #000;margin-bottom:10px">

</div>

<div style="float:left;width:15%;border:1px solid #000">
<ul style="margin-left:10px;list-style-type:none">
<li><a href="index.php">Home</a></li>
<li><a href="index.php?page=about">About</a></li>
<li><a href="index.php?page=contact">Contact</a></li>
</ul>
</div>

<div style="float:right;width:80%;border:1px solid #000">
<div style="padding:4px">


<?php

# default page
$default = 'home.php';

# set document root path
$base = $_SERVER['DOCUMENT_ROOT'];

# list of all site pages + the id they will be called by
$pages = array('about' => 'about.php','contact' => 'contact.php');

if(array_key_exists($_GET['page'], $pages))
{
foreach($pages as $pageid => $pagename) {
if($_GET['page'] == $pageid && file_exists($base.$pagename))
{
/* if somebody's making a request for ?page=xxx and
the page exists in the $pages array, we display it
checking first it also exists as a page on the server */
include $base.$pagename;
}
} // end foreach
}
else {
/* if the page isn't listed in $pages, or there's no ?page=xxx request
we show the default page, again we'll also just make sure it exists as a file
on the server */
if(file_exists($base.$default)) include $base.$default;
}

?>


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




and no, i'm not posting it now not to look dumb...too late

7/24/2006 10:41:18 PM

Noen
All American
31346 Posts
user info
edit post

next step is to see if the include file is working, echo the $base.$default and or $base.$page, see what they are actually trying to pull from.

it will most likely work if you just remove the $base string, since you are doing an include from the same directory

7/24/2006 10:53:56 PM

quagmire02
All American
44225 Posts
user info
edit post

i'll give that a shot tomorrow morning and we'll see what happens...thanks for looking at it

7/24/2006 10:55:11 PM

quagmire02
All American
44225 Posts
user info
edit post

^^ how do i echo it? which line(s) am i supposed to remove?

7/25/2006 9:01:47 PM

bous
All American
11215 Posts
user info
edit post

echo $base.$default;

7/26/2006 12:11:46 AM

quagmire02
All American
44225 Posts
user info
edit post

where do i type that in...i realize these are extremely n00b questions, and reading up the on the basics of PHP would be extremely helpful, but i don't really want to do much in PHP except this sort of thing, in order to make the coding on my site a little more efficient without using outdated frames...i'd use all include files, but my goal for this is simply to consolidate the menu coding

thanks for the help

7/26/2006 9:36:14 AM

 Message Boards » Tech Talk » PHP problem...what am i doing wrong? Page [1]  
go to top | |
Admin Options : move topic | lock topic

© 2024 by The Wolf Web - All Rights Reserved.
The material located at this site is not endorsed, sponsored or provided by or on behalf of North Carolina State University.
Powered by CrazyWeb v2.38 - our disclaimer.