Page 1 of 1

Problem with coding..

Posted: Tue Feb 28, 2006 7:42 am
by randome
I have a question regarding the php -code below:

<?php
if(!isset($_GET["page"])) { $sivu = "frontpage"; }
else { $page = $_GET["page"]; }
if(!file_exists($page . ".php")) { $page = "error"; }
include($page . ".php");
?>

I read from somewhere that the 'frontpage.php' must be in same directory with index.php, and yes for sure that way it works but..

-----

My question is. How to get 'frontpage' from somewhere else, from other folders? ( then the need is to put/write it only in one place like exemple 'menu.php')

Thank you for the help in advance,

Jarno

ps. if possible, please email me the answer: jarnopalonen@yahoo.com

Posted: Tue Feb 28, 2006 8:25 am
by CoderGoblin
First of all please use the php tag.

The actual thing you need to do is insert the path into the request such as

Code: Select all

<?php

define ('PAGE_PATH'='/subdir/');

if (!isset($_GET["page"])) {
  $sivu = "frontpage"; 
} else { 
  $page = $_GET["page"]; 
}
if (!file_exists(PAGE_PATH . $page . ".php")) {
   $page = "error"; 
} 
include(PAGE_PATH . $page . ".php");
?>
will get the page in the directory subdir below the top level.

Posted: Tue Feb 28, 2006 9:46 am
by feyd
switch the equal on the define line to a comma, however.

Just can't get it work..

Posted: Tue Feb 28, 2006 10:27 am
by randome
How about if someone could make that code just like it need to be in full for my site?

Here are the details;

On top level is directory named 'tarinat', and in there is directory/folder named 'liitteet'

Into index.php of directory 'liitteet' need to get the 'menu.php' from directory/folder 'tarinat'.

Yes, I've tried MANY ways allready, so please give me the whole code as it must put to the site.

Thank you for your co-operation :)

Re: Just can't get it work..

Posted: Tue Feb 28, 2006 6:25 pm
by Roja
randome wrote:Yes, I've tried MANY ways allready, so please give me the whole code as it must put to the site.
This is a *learning* site. We help you learn how to do things. Teach a man to fish and he can feed himself for life, ya know?

The alternative (giving you the finished product) is called work. Most people here get paid (a lot) to do that. In most discussions the rate is between $35-$65 US dollars per hour.

I'm sure someone is willing to do it at that rate. If you aren't willing to pay for someone to do work to specification, perhaps you might enjoy learning how to do it yourself, so you can one day charge others.

That service - teaching you a valuable skill - we offer for free here. What a value.

Posted: Tue Feb 28, 2006 7:15 pm
by John Cartwright
*going to quote Roja next time this comes up again* :wink:

Well well

Posted: Wed Mar 01, 2006 3:33 am
by randome
You wait me or someone else to pay for your 'help'??

Is that the reason why you're living your life in these kind of places, 'my 10 last years in the forum'? (it can be like this too..the same 'my 10 last years in the toilet')

We've been following people like you're, and all ower the world/Internet. You have NO life outside of these forums. Tell me I'm wrong? No, you can't because I am not wrong.

By the way. I solv the problem abowe. Great a? It wasn't real hard work, just look at it 2 times more and that's it. And you <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span> ask money for that? Lick your bulls...or let your mother continue on it.

Re: Just can't get it work..

Posted: Wed Mar 01, 2006 3:44 am
by duk
please see what you wrote..
randome wrote: Yes, I've tried MANY ways allready, so please give me the whole code as it must put to the site.
i think make sense what he said... but you have a section to ask someone to doo your work for free.. but for sure this is not the correct place...

viewforum.php?f=26

Re: Well well

Posted: Wed Mar 01, 2006 6:51 am
by Roja
randome wrote:You wait me or someone else to pay for your 'help'??
Ahem. Read it again - I didn't ask you to pay me. (In fact, I almost never do contract work anymore, because my day job keeps my extremely happy financially).

I enjoy helping people - not working for them. I was making clear to you what the difference was. You weren't asking for help, you were asking people to do work for you.
randome wrote:We've been following people like you're, and all ower the world/Internet. You have NO life outside of these forums. Tell me I'm wrong? No, you can't because I am not wrong.
Personal attacks on members of this forum are not welcome, nor allowed. I happen to have an extremely pleasant life "in real life", far from these forums. I come here to help people, which I enjoy.

Please try to show a little respect for people trying to help others. Its the forum rules, and if you don't like it, please don't visit.
randome wrote:By the way. I solv the problem abowe. Great a? It wasn't real hard work, just look at it 2 times more and that's it.
Great! Glad to hear it. Please help others by following up, and posting what the solution was, so that they can learn from your situation too. Thats how these forums become useful.

I'm sorry you felt insulted by my comments. That wasn't the intent. I wanted you to understand that the forums are here to help people - not do their work for them. (Unless you want to pay people, or ask for volunteers).