?
Solved

Website not finding calling index.php

Posted on 2007-03-24
8
Medium Priority
?
273 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

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!

Question has a verified solution.

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

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.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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 …
Suggested Courses
Course of the Month16 days, 9 hours left to enroll

864 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