Solved

Website not finding calling index.php

Posted on 2007-03-24
8
258 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
  • 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 250 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

This article discusses four methods for overlaying images in a container on a web page
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

749 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