?
Solved

Website not finding calling index.php

Posted on 2007-03-24
8
Medium Priority
?
262 Views
Last Modified: 2013-12-13
Hi Okay, hard to explain this.

I have a php script index.php,  which loads some html and when you select a link it calls itself (index.php) passing in for example /?a=authors. I then switch($_REQUEST["a"])  based on the param i set.

The problem is this: My web account is on a shared machine and I have an acount on this with a public_html folder as follows: http://www.skynet.ie/~geronimo
 When I click on a link though it only picks up the webhost http://www.skynet.ie and not my accuont.
So it does not find the index.php.

I bascially need a bit more info on how you can make my php code knows where it is in relation to iself. I.e sometimes it sees the calling page as http://www.skynet.ie/ and sometimes it sees
http://www.skynet.ie/~geronimo

Cheers Dave



0
Comment
Question by:9703403
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 14

Expert Comment

by:Aamir Saeed
ID: 18786537
try giving path

http://www.skynet.ie/~geronimo/

i.e. trailing slash
0
 

Author Comment

by:9703403
ID: 18786582
Where should I set that though ?

When I load
http://www.skynet.ie/~geronimo/
it auto calls the index.php but if I cliick on a link it thinks its http://www.skynet.ie
0
 
LVL 14

Expert Comment

by:Aamir Saeed
ID: 18786594
where you are clicking the links
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 18786597
>> When I click on a link though it only picks up the webhost http://www.skynet.ie and not my accuont.

What is the code that does this?  The question and what is happening still isn't clear and you code will help.  I agree that this maybe hard to explain but maybe reread the post to see if there is something obvious to clear up.

bol
0
 

Author Comment

by:9703403
ID: 18786656
Okay code is here and website is here:   http://www.skynet.ie/geronimo/index.php 
When you click for example on the authors link i have is set so it passes in /?a=authors
But if you hover over the link you can see  http://www.skynet.ie/?a=authors
it is it has left out the ~geronimo/index.php
So I get a missing page problem. Why wont it pick up the full url ?


0
 
LVL 24

Accepted Solution

by:
glcummins earned 1000 total points
ID: 18786664
The problem is caused when you use a link like this:

<a href="/?a=authors">Link</a>

When you start the url with a slash ('/'), you are telling the webserver to get the document from the very top level of the current webserver. In your case, that would be "http://www.skynet.ie/". It is shorthand for the following:

 http://www.skynet.ie/?a=authors

Obviously, that is not the location you intend. Instead, in the link you need to use:

 /~geronimo/?a=authors

This is shorthand for:

 http://www.skynet.ie/~geronimo/?a=authors

which will call your index.php script. Just make sure to include your subdirectory in your link href, and you will get to the correct location.
0
 

Author Comment

by:9703403
ID: 18786700
Omg Thanks a million. How simple was that. I feel stupid :(

Appreciate the help. Cheers Dave

0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 18786705
The suggestion above may be all you need but it would still mean the URL in specific to the page and not relative.  Leave the trailing slash off.  The URL isn't even really valid since it doesn't have a file name.  I suggest you would simplify it if you just used ...

href="<?php= $_SERVER["PHP_SELF"] ?>?a=authors

The result will be a correct, relative url no matter where the page is.  In other words the same script could be used in the page in either directory.

Let me know if you have a question or need more info.

bol
0

Featured Post

7 Extremely Useful Linux Commands for Beginners

Just getting started with Linux? Here's a quick start guide that has 7 commands that we believe will come in handy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question