sval Posted August 11, 2008 Share Posted August 11, 2008 I'm going to try and explain this coherently :-\ I have a form (members.php) that calls a php file (query_gigs3d.php) which accesses a mysql database. The php file creates a list of links on the original form page. Then when the user clicks on a link it takes them to details of that link. On the working server, the path shown after clicking a link is something like this: http://uxguru.metanoiadesign.com/login/members/query_gigs3d.php?id=3 ...and a details page is displayed. On the server that doesn't work it looks like this: http://www.uxguru.net/login/members/members.php?id=14 ...and the original members.php page is re-displayed. I'm using the same files on each server (linux) Both databases are MySql 5.0 with the same configuration. I'm going crazy trying to figure what is going on ??? Does anyone have any idea? Quote Link to comment https://forums.phpfreaks.com/topic/119220-solved-path-problem-on-one-server-but-works-fine-on-another/ Share on other sites More sharing options...
akitchin Posted August 11, 2008 Share Posted August 11, 2008 it would help to see some code, perhaps query_gigs3d.php, or perhaps members.php. in particular, pay attention to any $_SERVER variables used in the code. Quote Link to comment https://forums.phpfreaks.com/topic/119220-solved-path-problem-on-one-server-but-works-fine-on-another/#findComment-614038 Share on other sites More sharing options...
sval Posted August 12, 2008 Author Share Posted August 12, 2008 Interesting that you should mention $_SERVER variables. I'm using a purchased login script and when I tried to install the script on the new server I was getting a call-time-pass-by-reference error. So I was told by their support to do the following: Change: if ( $this->ip_valid ( &$_SERVER [ $c ] ) ) { To: if ( $this->ip_valid ( $_SERVER [ $c ] ) ) { I wonder if this could be the problem? It is a snippet from a file in lib. So I wonder how I fix it? If you still need more info, like the member and query_gigs files, I can download them too. Just don't want to do an avalanche of code if its not needed. Quote Link to comment https://forums.phpfreaks.com/topic/119220-solved-path-problem-on-one-server-but-works-fine-on-another/#findComment-614132 Share on other sites More sharing options...
akitchin Posted August 12, 2008 Share Posted August 12, 2008 i'm not sure i could tell you from that block. it's not likely, since passing by reference with any other variable would often make a difference (the reason one does it is to affect the global scope value for that var, rather than the function scope's value), but $_SERVER is editable from everywhere because it's a superglobal. if we could see the following two items, it might be a good place to start to avoid said avalanche: - the form's HTML code (where it is echoed, notably the <form> tag), and - the code that outputs the list of links only (none of the periphery, if you know how to discriminate) Quote Link to comment https://forums.phpfreaks.com/topic/119220-solved-path-problem-on-one-server-but-works-fine-on-another/#findComment-614531 Share on other sites More sharing options...
sval Posted August 12, 2008 Author Share Posted August 12, 2008 okay, here goes... FORM: <script language="javascript" type="text/javascript"> <!-- ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){ var ajaxDisplay = document.getElementById('listDiv'); ajaxDisplay.innerHTML = ajaxRequest.responseText; } var city = document.getElementById('city').value; var duration = document.getElementById('duration').value; var queryString = "?city=" + city + "&duration=" + duration; ajaxRequest.open("GET", "query_gigs3d_test.php" + queryString, true); ajaxRequest.send(null); } //--> </script> <p><form name='myForm'> <label class="browse">City: <br><input type='text' id='city' /></label></p> <p><label class="browse">Desired job functions&</label> <p><label class="browse">Duration: <br><select id='duration'> <option value="Contract">Contract</option> <option value="Permanent">Permanent</option> </select></label></p> <br> <input type='button' onclick='ajaxFunction()' value='Browse Jobs' /> </FORM> STUFF from query gigs: while($row = mysql_fetch_array($qry_result)){ printf("<a href=\"%s?id=%s\">%s</a>, %s %s<br>", $PHP_SELF, $row["id"], $row["job_title"], $row["company"], $row["city"]); } if ($id) { $result = mysql_query("SELECT * FROM gig_table WHERE id=$id"); $row = mysql_fetch_array($result); printf("<html><title>UXGuru.com - Job Description</title><head> <LINK rel=\"stylesheet\" type=\"text/css\" href=\"../css/basic_styles.css\"></head><body>"); printf("<p class=\"medium\">Company: %s\n<br>", $row["company"]); printf("Job Function: %s\n<br>", $row["int_design"]); printf("Job Title: %s\n<br>", $row["job_title"]); ...etc. Quote Link to comment https://forums.phpfreaks.com/topic/119220-solved-path-problem-on-one-server-but-works-fine-on-another/#findComment-614733 Share on other sites More sharing options...
akitchin Posted August 12, 2008 Share Posted August 12, 2008 it would appear this is where your code is going astray: printf("<a href=\"%s?id=%s\">%s</a>, %s %s<br>", $PHP_SELF, $row["id"], $row["job_title"], $row["company"], $row["city"]); you'll probably find that $PHP_SELF is defined differently on both servers, leading to the incorrect links. do you know where that's being defined? Quote Link to comment https://forums.phpfreaks.com/topic/119220-solved-path-problem-on-one-server-but-works-fine-on-another/#findComment-614742 Share on other sites More sharing options...
sval Posted August 12, 2008 Author Share Posted August 12, 2008 both servers are shared hosts on godaddy. not sure why one would different from the other but what you say makes sense. is there another way I can refer to the query_gigs page besides $PHP_SELF because I may not be able to change how it is defined. Quote Link to comment https://forums.phpfreaks.com/topic/119220-solved-path-problem-on-one-server-but-works-fine-on-another/#findComment-614991 Share on other sites More sharing options...
akitchin Posted August 12, 2008 Share Posted August 12, 2008 you could try using $_SERVER['PHP_SELF']; i'm not sure if the script is relying upon register_globals being on or off, but that could also be the difference. check the php_info() function on both and see if one is on and one is off. Quote Link to comment https://forums.phpfreaks.com/topic/119220-solved-path-problem-on-one-server-but-works-fine-on-another/#findComment-615029 Share on other sites More sharing options...
sval Posted August 13, 2008 Author Share Posted August 13, 2008 I did try $_SERVER[php_SELF] and it got me part way there. It now goes to the query_gigs page but does not display the dynamic details of the link that PHP_SELF was a part of. It starts at the top of the query_gigs file and doesn't seem to find the dynamic stuff. Here is the most of the file in case you have any ideas. // Retrieve data from Query String $city = $_GET['city']; $duration = $_GET['duration']; // Escape User Input to help prevent SQL Injection $city = mysql_real_escape_string($city); $duration = mysql_real_escape_string($duration); //build query $query = "SELECT * FROM gig_table WHERE duration = '$duration'"; if($city) $query .= " AND city = '$city'"; //Execute query $qry_result = mysql_query($query) or die(mysql_error()); // Display a new row for each person returned while($row = mysql_fetch_array($qry_result)){ printf("<a href=\"%s?id=%s\">%s</a>, %s %s<br>", $_SERVER['PHP_SELF'], $row["id"], $row["job_title"], $row["company"], $row["city"]); } if ($id) { $result = mysql_query("SELECT * FROM gig_table WHERE id=$id"); $row = mysql_fetch_array($result); printf("<html><title>UXGuru.com - Job Description</title><head> <LINK rel=\"stylesheet\" type=\"text/css\" href=\"../css/basic_styles.css\"> </head><body>"); printf("<table width=\"800\" align=\"center\"><tr><td><div id=\"container\"><div id=\"header\"><h1 class=\"float_left\">UXGuru</h1></div><div id=\"wrapper\"><div id=\"content\"><p> </p>"); printf("<p class=\"medium\">Company: %s\n<br>", $row["company"]); printf("Job Function: %s\n<br>", $row["int_design"]); printf("Job Title: %s\n<br>", $row["job_title"]); printf("City: %s\n<br>", $row["city"]); printf("Duration: %s\n</p>", $row["duration"]); printf("<p class=\"medium\">Job Description: %s\n</p>", $row["description"]); printf("</p></div></div><div id=\"footer\"><p><a href=\"http://uxguru.metanoiadesign.com/members/members.php\">Home</a> | <a href=\"http://uxguru.metanoiadesign.com/about.php\">About</a> | <a href=\"http://uxguru.metanoiadesign.com/contact.php\">Contact Us</a></p></div></div></td></tr></table>"); printf("</body></html>"); } Quote Link to comment https://forums.phpfreaks.com/topic/119220-solved-path-problem-on-one-server-but-works-fine-on-another/#findComment-615972 Share on other sites More sharing options...
akitchin Posted August 13, 2008 Share Posted August 13, 2008 try replacing $id with $_GET['id'] - register_globals is likely not on for this server, and it should never be on (or relied upon). Quote Link to comment https://forums.phpfreaks.com/topic/119220-solved-path-problem-on-one-server-but-works-fine-on-another/#findComment-615977 Share on other sites More sharing options...
sval Posted August 14, 2008 Author Share Posted August 14, 2008 That did it! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/119220-solved-path-problem-on-one-server-but-works-fine-on-another/#findComment-616596 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.