Jump to content

[SOLVED] path problem on one server but works fine on another


Recommended Posts

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?

 

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.

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)

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.

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?

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.

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.

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>");

}

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.