Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Website not finding calling index.php

Posted on 2007-03-24
8
Medium Priority
?
268 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
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

618 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