Problem :(

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Problem :(

Post by Dale »

OK Thank you to the person who showed me about how to make pages with the address:
http://www.blahblahblah.com/index.php?id=01 ect...

Now my menu is on everyone of my pages and if i haveto update anything i have to edit it over 20 times which is kinda boring so i know about the INCLUDE tag but for some reason it don't work inside the tags that make your page have the index.php?id=1 at the end.

Please Help!
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Well what does your code look like? It's easier to help you when we can see what you've attempted. Once thing though, include() isn't a tag (it's PHP and tags are something that you get in HTML) so if you are trying to do something like <include>...</include> it's definitely not going to work.

Mac
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

Heres just one of my pages:

Code: Select all

<?php 
switch ($id) &#123; 
   case 0: 
      echo "<? include("compteur.php"); ?>
<html>
<head>
<title>Dales UT2K3 Database</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#000000" text="#CCCCCC" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" bottommargin="0" rightmargin="0" link="#CCCCCC" vlink="#CCCCCC" alink="#CCCCCC">
<table width="1005" border="0" cellspacing="0" cellpadding="0" height="100%">
<tr> 
<td width="150" height="150"><font size="1" face="Verdana">
<img src="./images/tl.jpg" width="150" height="150"></font></td>
<td width="855" colspan="3">
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%" background="./images/tbg.jpg">
<tr>
<td><font size="1" face="Verdana">
<img src="./images/tl3.jpg" width="100" height="150"></font></td>
<td width="100%">&nbsp;</td>
<td><font size="1" face="Verdana">
<img src="./images/tr.jpg" width="500" height="150"></font></td>
</tr>
</table>
</td>
</tr>
<tr> 
<td rowspan="2" width="150"> 
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%" background="./images/lbg.jpg">
<tr> 
<td><font size="1" face="Verdana">
<img src="./images/tl2.jpg" width="150" height="188"></font></td>
</tr>
<tr> 
<!--Main Menu Start-->
<td height="100%" valign="top"><font face="Verdana" size="1"><b>&nbsp;Main Menu</b><br>
&nbsp;&nbsp;<a href="http://www.imahosting.com/dale/test/index.php">Home</a><br>
&nbsp;&nbsp;<a href="http://www.imahosting.com/dale/test/forums/">Forum</a><br>
&nbsp;&nbsp;<a href="http://www.imahosting.com/dale/test/index.php?id=1">Staff</a><br>
&nbsp;&nbsp;<a href="mailto:dale@host.sk">Contact Me</a><br><br>

&nbsp;<b>UT2K3 Stuff<br></b>
&nbsp;&nbsp;<a href="http://www.imahosting.com/dale/test/index.php?id=2">Info</a><br>
&nbsp;&nbsp;<a href="http://www.imahosting.com/dale/test/index.php?id=3">Cheats</a><br>
&nbsp;&nbsp;<a href="http://www.imahosting.com/dale/test/index.php?id=4">Demos</a><br>
&nbsp;&nbsp;<a href="http://www.imahosting.com/dale/test/index.php?id=5">Gallery</a><br>
&nbsp;&nbsp;<a href="http://www.imahosting.com/dale/test/index.php?id=6">Maps</a><br>
&nbsp;&nbsp;<a href="http://www.imahosting.com/dale/test/index.php?id=7">Mods</a><br>
&nbsp;&nbsp;<a href="http://www.imahosting.com/dale/test/index.php?id=8">Mutators</a><br>
&nbsp;&nbsp;<a href="http://www.imahosting.com/dale/test/index.php?id=9">Patches</a><br>
&nbsp;&nbsp;<a href="http://www.imahosting.com/dale/test/index.php?id=10">Skins</a><br>
&nbsp;&nbsp;<a href="http://www.imahosting.com/dale/test/index.php?id=11">Sounds</a><br>
&nbsp;&nbsp;<a href="http://www.imahosting.com/dale/test/index.php?id=12">Videos</a><br>
&nbsp;&nbsp;Submit<br><br>

&nbsp;<b>Counter<br></b>
&nbsp;&nbsp;<? echo $hits; ?>

</font></td>
</tr>
<tr> 
<td>&nbsp;</td>
</tr>
</table>
</td>
<!--Main Menu End-->
<td valign="top" width="5"> 
<p align="center"><font size="1" face="Verdana"><br></font></p>
</td>
<td valign="top" width="776"> 

<p align="center"><br>
<a href="http://www.gamer.uk.com/cgi-bin/aff_jump.cgi?uid=utdale">
<font size="1" face="Verdana">
<img src="http://www.gamer.uk.com/banners/pc/u2_468_pc.gif" border="0" width="468" height="60"></font></a></p>
<p align="center"><font size="1" face="Verdana">News </font>
<p align="left">
<--News-->
<p>&nbsp;</td>
<td valign="top" width="5"> 

</td>
</tr>
<tr>
<td valign="bottom" width="855" colspan="3"> 
<p align="center"><font face="Verdana" size="1">Site Designed By <a href="http://www.imahosting.com/cicid/">
Ciced</a></font></td>
</tr>
</table>
</body>
</html>";
      break;
and i want the menu section (From <!--Main Menu Start-->
to <!--Main Menu End-->
) as the include thing.
Litazia Tanxashira
Forum Newbie
Posts: 3
Joined: Tue Jun 25, 2002 5:46 pm

Um O.o

Post by Litazia Tanxashira »

May I make a couple of suggestions?

"<?php" and "?>" are your friends. So, instead of echoing all of that *shudder*, do this:

Code: Select all

switch ($id) &#123;
    case 0:
        include("compteur.php");
?>
<!-- your HTML goes here -->
<?php
        break;
etc...
&#125;
Better yet, why not stick all the HTML into one file, and call it something like page0.php (or whatever)? Then you'd get this:

Code: Select all

switch ($id) &#123;
    case 0:
        include("compteur.php");
        include("page0.php"); 
        break;
etc...
&#125;
That way, you can write it in as pure HTML, and you don't have to escape every single special character you come across. And, for that matter, it makes it easier to read. So, when you come back to it in a year, say, you're not clawing your eyes out! :) (It makes it even better if other people have to debug your code. You want to make their lives happy, because you sure as heck wouldn't want other people to make your life miserable!)

Now, as for your menu: Stick all of that (as pure HTML) into a file (let's call it mainmenu.php). Now, we go back to page0.php (as I called it earlier). What you do is this:

Code: Select all

<!--Main Menu Start-->

<?php
include("mainmenu.php");
?>

<!--Main Menu End-->
(Note that having the "<?php" and "?>" tags on separate lines like that is personal preference. AFAIK, it's entirely acceptable to have all of that on one line.)

So, now that the menu's in one file, you can edit just the one file, and everything will be happy :)
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

Thx i'll try it
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /var/www/html/dale/test/index.php on line 50
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

BUMP

HELP!
PLEASE!
Litazia Tanxashira
Forum Newbie
Posts: 3
Joined: Tue Jun 25, 2002 5:46 pm

Post by Litazia Tanxashira »

What's on (and around) line 50?
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

include("mainmenu.php");
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

Dale, whats ON line 50 as well as the lines AROUND line 50.
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

As i said before:

Line 50:
include("mainmenu.php");
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

So there is nothing on lines 44 - 49 and 51 - 56? I mean, it would help to have what's also AROUND line 50.
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

Code: Select all

<?php 
include("mainmenu.php"); 
?>
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Is that all that's in the file - the error is blantantly not in your include bit so in order to help you we really need to see what scripting you have above it.

Mac
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

Code: Select all

<?php 
switch ($id) &#123; 
   case 0: 
      echo "<? include("compteur.php"); ?> 
<html> 
<head> 
<title>Dales UT2K3 Database</title> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
</head> 

<body bgcolor="#000000" text="#CCCCCC" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" bottommargin="0" rightmargin="0" link="#CCCCCC" vlink="#CCCCCC" alink="#CCCCCC"> 
<table width="1005" border="0" cellspacing="0" cellpadding="0" height="100%"> 
<tr> 
<td width="150" height="150"><font size="1" face="Verdana"> 
<img src="./images/tl.jpg" width="150" height="150"></font></td> 
<td width="855" colspan="3"> 
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%" background="./images/tbg.jpg"> 
<tr> 
<td><font size="1" face="Verdana"> 
<img src="./images/tl3.jpg" width="100" height="150"></font></td> 
<td width="100%">&nbsp;</td> 
<td><font size="1" face="Verdana"> 
<img src="./images/tr.jpg" width="500" height="150"></font></td> 
</tr> 
</table> 
</td> 
</tr> 
<tr> 
<td rowspan="2" width="150"> 
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%" background="./images/lbg.jpg"> 
<tr> 
<td><font size="1" face="Verdana"> 
<img src="./images/tl2.jpg" width="150" height="188"></font></td> 
</tr> 
<tr> 
<!--Main Menu Start--> 
<?php 
include("mainmenu.php"); 
?>
<!--Main Menu End--> 
<td valign="top" width="5"> 
<p align="center"><font size="1" face="Verdana"><br></font></p> 
</td> 
<td valign="top" width="776"> 

<p align="center"><br> 
<a href="http://www.gamer.uk.com/cgi-bin/aff_jump.cgi?uid=utdale"> 
<font size="1" face="Verdana"> 
<img src="http://www.gamer.uk.com/banners/pc/u2_468_pc.gif" border="0" width="468" height="60"></font></a></p> 
<p align="center"><font size="1" face="Verdana">News </font> 
<p align="left"> 
<--News--> 
<p>&nbsp;</td> 
<td valign="top" width="5"> 

</td> 
</tr> 
<tr> 
<td valign="bottom" width="855" colspan="3"> 
<p align="center"><font face="Verdana" size="1">Site Designed By <a href="http://www.imahosting.com/cicid/"> 
Ciced</a></font></td> 
</tr> 
</table> 
</body> 
</html>"; 
      break;
Theres all the code for my index page and i kindaneed this problem fixeds by tomorrow. Just copy and paste the code and have a mess around and see what you can do.
Post Reply