Web Hosting Talk







View Full Version : PHP settings for Biz Directory Script


JasonTNYC
12-11-2004, 09:14 AM
Hello All-

I am having a bit of difficulty (See Below) running a PHP directory script. Hopefully I have posted this in the correct category. I have a nagging feeling my problems are being caused by an incorrect setting in either PHP or mySQL. Could someone take a look at my PHP settings and let me know if something is set incorrectly. My config is here --> http://www.kwikgoblin.com/phpinfo.php My issues are two fold.

1.) I seem to have a problem holding a log-in with some of the directories I have tried to install. It queries the mySQL database and returns that the login is correct but as soon as I try to do anything, it loses the login (returning to the login screen)

2.) With Biz Directory in particular, If you try to suggest a url from the main page - www.kwikgoblin.com it goes to http://add_url.php/?c=1 instead of http://www.kwikgoblin.com/add_url.php/?c=1

If you put the second url in by hand it brings you to the correct "suggest a url" page. But then notice when you mouseover the Kwik Goblin text link you get http:///

It obviously is using a slash instead of the root url.
It seems to be the $dir variable that isn't correct

It pulls it from this include which seems to be the issue


<?
ini_set("register_globals", "0");
$dir = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$dir = substr($dir,0,strrpos($dir, "/"))."/";
if (is_array($_GET) || is_array($_POST)){
if (getenv("REQUEST_METHOD") == "POST"){
extract($_POST);
}else{
extract($_GET);
};
};
Code Continues After this point.............

This is the only config file which is for the mySQL database:



<?
$mysql_hostname = "mysql.*******.com";
$mysql_user = "*******";
$mysql_password = "*******";
$mysql_database = "kwikgoblin";
$prefix = "dir_";
$show_additional_results = TRUE; // TRUE OR FALSE
$bannerboxes_id = "f48a32ca-72a7-498d-8a49-66e5b2e3093c";
// Get your own id at http://www.bannerboxes.com?affid=f66b05a0-7274-4701-9183-b075e015c6af
// and start earning money with your directory!
?>

Is it possible it is either a PHP setting or a setting in mySQL?

Thanks in advance

PaddysPlace
12-11-2004, 01:00 PM
Can you post the code that results in the blank (http://) link? I am curious to see what code you are using to print it. My guess is that if you are using variable to store yor main website, there is a misprint in it. So what you think would be http://www.yourdomain.com/yourpage.php becomes http://yourpage.php . Notice how this is all a result of one variable.


Regards,
Patrick

PaddysPlace
12-11-2004, 01:04 PM
After checking it out, the reason it is not printing it is because of your substr line. This appears to delete the entire $dir variable. For what reason are you using this?

Regards,
Patrick

JasonTNYC
12-11-2004, 02:15 PM
Originally posted by PaddysPlace
After checking it out, the reason it is not printing it is because of your substr line. This appears to delete the entire $dir variable. For what reason are you using this?


I'm not sure why that is in there - I am using the code unaltered at this point (Someone else put this on one of their domains with no issues to test it for me)

Can you post the code that results in the blank (http://) link?
Here you go:
<?
require_once("config.php");
require_once("include.php");
require_once("template_add_url.php");
$c *= 1;
if ($c == 0){
header("Location: {$dir}");
exit();
};

This is the code that displays the link that results in http:/// which basically means it sees $dir = /

JasonTNYC
12-11-2004, 02:22 PM
If I take out this line

$dir = substr($dir,0,strrpos($dir, "/"))."/";

I get this web address for the links:

http://www.kwikgoblin.comadd_url.php/?c=1

instead of how it should be

http://www.kwikgoblin.com/add_url.php/?c=1


so I am assuming that that piece of code is Supposed to put the / divider between the root url and the page it is going to

but instead it clears out the root domain

PaddysPlace
12-12-2004, 12:28 AM
Jason,

Seeing as the subtr() is serving no purpose but the ."/" is... Try this:


<?
ini_set("register_globals", "0");
$dir = "http://".$_SERVER['HTTP_HOST'] . "/" . $_SERVER['REQUEST_URI'];
if (is_array($_GET) || is_array($_POST)){
if (getenv("REQUEST_METHOD") == "POST"){
extract($_POST);
}else{
extract($_GET);
};
};
Code Continues After this point.............


Regards,
Patrick

JasonTNYC
12-12-2004, 07:43 AM
It actually turned out to be one of my hosting companys settings. I am trying to track down which one as it would help others I am sure.

I switched hosting companies, moved the files, and it instantly worked.

Thanks for everyones assistance.