4 Replies - 346 Views - Last Post: 29 November 2012 - 04:48 PM

#1 Bestford  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 44
  • Joined: 05-December 11

file paths: Menu problems

Posted 29 November 2012 - 02:48 PM

hello guys,

I'm trying to sort out my menu file system out and im having massive issues,

<?php
if ($_SERVER['HTTP_HOST']=='localhost') {
	$path = '/local-html/lr';
	ini_set('display_errors', true);
	error_reporting(-1); // show all errors
} else {
	$path = '/var/www/vhosts/numyspace.co.uk/web_users/home/~unn_w10011815/public_html/lr';
	ini_set('display_errors', false);
	error_reporting(-1); // show no errors
}
set_include_path(get_include_path() . PATH_SEPARATOR . $path);

?>
<nav>
	<ul>
		<li><a href="index.php">Home</a></li>
		<li><a href="calendar.php">Calendar</a></li>
		<li><a href="messaging.php">Program and Module Messaging</a></li>
		<li><a href="questionnaire.php">Questionnaire</a></li>
		<li><a href="auction.php">Auction</a></li>
	</ul>
</nav>



basically what this should do is set a starting path for all files to start from however it either isnt doing that or something is wrong (my lecturer wrote this code and he said it should work but ive spent ages on it and it wont)

when i use the menu normally I can use it as expected, however when i go into a file that is held in a folder eg. admin folder to use other functions it doesnt work i get this :

Error:
Not Found

The requested URL /~unn_w10011815/lr/admin/index.php was not found on this server.

what it should call is /~unn_w10011815/lr/index.php and it doesnt

any help
regards
Bestford

Is This A Good Question/Topic? 0
  • +

Replies To: file paths: Menu problems

#2 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1183
  • View blog
  • Posts: 7,253
  • Joined: 07-September 06

Re: file paths: Menu problems

Posted 29 November 2012 - 03:47 PM

Your links are doing exactly what they are told to do, the problem is you aren't telling them what you think you are.

The links are all processed by the client, meaning that they have no access to the PHP you are running above, only what it outputs.

With the link:
<a href="messaging.php">Program and Module Messaging</a>


The browser will see that it is only given a relative path, instead of a full path, and use (by default) the current directory. That means if you were at http://www.example.c...path/index.html it would take you to http://www.example.c...h/messaging.php.

Now, if you want it to go to a different path, you have to specify that. For example, if you wanted to go to http://www.example.c...m/messaging.php[/il] you would use this link:
<a href="../messaging.php">Program and Module Messaging</a>


The include path you are setting above tells PHP where it should look for files to include when told to include a file. More information can be found here: http://us1.php.net/m...nclude-path.php

Hopefully that makes sense.
Was This Post Helpful? 0
  • +
  • -

#3 Bestford  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 44
  • Joined: 05-December 11

Re: file paths: Menu problems

Posted 29 November 2012 - 04:14 PM

bit if i do ../messaging then the files that arent in a dir will go back a further dir so then it wont work

As im Including this file in all files, is there any other solution?
Was This Post Helpful? 0
  • +
  • -

#4 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1183
  • View blog
  • Posts: 7,253
  • Joined: 07-September 06

Re: file paths: Menu problems

Posted 29 November 2012 - 04:36 PM

If you give the absolute path it will work regardless of where you are.

For example:
<a href="http://www.example.com/somepath/to/a/file/messaging.php">Messaging</a>

Was This Post Helpful? 0
  • +
  • -

#5 Bestford  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 44
  • Joined: 05-December 11

Re: file paths: Menu problems

Posted 29 November 2012 - 04:48 PM

yeah i believe thats what I'm going to have to do as ive tried everything and its a pain in the backside now been trying to get around doing it for a couple of days so yeah il just do an absolute path

thanks
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1