laanes Posted September 3, 2010 Share Posted September 3, 2010 On a website currently under development the URL does not change when navigating around on the page. It always displays the root URL. This is the script that should generate the links: $URLvars=substr($_SERVER["PHP_SELF"], strrpos($_SERVER["PHP_SELF"],"/")+1); $vatLink=$URLvars; $thisPageURL=$_SERVER["PHP_SELF"]; if(strpos($thisPageURL, "secure/locktech/")!==false)$thisPageURL=substr($_SERVER["PHP_SELF"], 16); $prodLink="http://www.lock-tech.co.uk".$thisPageURL; It used to. However, the server has changed and it does not any more. Is it maybe because the 2 paths (http://www.lock-tech.co.uk and secure/locktech/) must be changed according to the new server? Does anyone know what exactly do these paths stand for? I understand that one of them is the root path but what does the path in the line if(strpos($thisPageURL, "secure/locktech/")!==false)$thisPageURL=substr($_SERVER["PHP_SELF"], 16); stand for? Link to comment https://forums.phpfreaks.com/topic/212423-url-not-being-generated/ Share on other sites More sharing options...
Onloac Posted September 3, 2010 Share Posted September 3, 2010 What changed on your server? What does that code produce? Do you get any errors? Link to comment https://forums.phpfreaks.com/topic/212423-url-not-being-generated/#findComment-1106753 Share on other sites More sharing options...
laanes Posted September 3, 2010 Author Share Posted September 3, 2010 .... That's a good point. I will try this out and let you know about the result. Link to comment https://forums.phpfreaks.com/topic/212423-url-not-being-generated/#findComment-1106754 Share on other sites More sharing options...
Onloac Posted September 3, 2010 Share Posted September 3, 2010 Actually, i thought I spotted a problem but was wrong so I removed the post. =p Link to comment https://forums.phpfreaks.com/topic/212423-url-not-being-generated/#findComment-1106755 Share on other sites More sharing options...
laanes Posted September 3, 2010 Author Share Posted September 3, 2010 What changed on your server? What does that code produce? Do you get any errors? The hosting changed. Old server: MySQL - 5.0.45 MySQL client version: 5.0.22 New server: Server version: 5.0.91-community MySQL client version: 5.0.91 The code attempts to generate the URL links by using the filename of the currently executing script, relative to the document root: www.myroot.co.uk/filename.php The errors I get: Notice: Undefined index: vat in /home/swansea3/public_html/lock-tech.co.uk/home/scrptz/sessions.php on line 39 Notice: Undefined index: action in /home/swansea3/public_html/lock-tech.co.uk/home/scrptz/sessions.php on line 62 Notice: Undefined index: UPDATE_x in /home/swansea3/public_html/lock-tech.co.uk/home/scrptz/sessions.php on line 62 Notice: Undefined index: DELETE_x in /home/swansea3/public_html/lock-tech.co.uk/home/scrptz/sessions.php on line 62 Notice: Undefined index: page in /home/swansea3/public_html/lock-tech.co.uk/home/groups.php on line 6 The code: <?php $GLOBALS['now']=gmdate('D, d M Y H:i:s').' GMT'; header('Expires: '.$GLOBALS['now']); // rfc2616 - Section 14.21 header('Last-Modified: '.$GLOBALS['now']); header('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 header('Pragma: no-cache'); // HTTP/1.0 // Clean all GET vars and stick them into an array foreach($_GET as $varName=>$value)$getVars[$varName]=trim(clean($value, 60)); // Clean all POST vars and stick them into an array foreach($_GET as $varName=>$value)$postVars[$varName]=trim(clean($value, 60)); // Start session if none active if(!$getVars["uid"])startSession(); // Read session vars readSessionVars($getVars["uid"]); // Start a new session if the previous one has timed out if((time()-$sessions["theTime"])>1800) { // destroySession($sessions["ID"]); $notify=" onload=\"alert('Your session has timed out!');\""; startSession(); readSessionVars($getVars["uid"]); } else { unset($notify); // Update session time updateSession($sessions["ID"], "theTime", time()); } // Get discount level from session $discLevel=$discArray[$sessions["discount"]]; // Update VAT session var if necessary if($getVars["vat"])updateSession($sessions["ID"], "vat", $getVars["vat"]); // Generate links for navigation, VAT and bookmarking $URLvars=substr($_SERVER["PHP_SELF"], strrpos($_SERVER["PHP_SELF"],"/")+1); $vatLink=$URLvars; $thisPageURL=$_SERVER["PHP_SELF"]; if(strpos($thisPageURL, "secure/locktech/")!==false)$thisPageURL=substr($_SERVER["PHP_SELF"], 16); $prodLink="http://www.lock-tech.co.uk/home/".$thisPageURL; // Put all GET vars into vars for navigation, VAT and direct link $varDiv="?"; foreach($getVars as $varName=>$value) { if($varName!="vat" && $varName!="SCode" && $varName!="qty" && $varName!="price" && $varName!="action" && $varName!="UPDATE_x" && $varName!="UPDATE_y" && $varName!="DELETE_x" && $varName!="DELETE_y") { if($varName!="uid" && $varName!="goto")$prodLink.=$varDiv.$varName."=".$value; // Direct link if($varName!="logError")$vatLink.=$varDiv.$varName."=".$value; // VAT if($varName!="page" && $varName!="index")$URLvars.=$varDiv.$varName."=".$value; // NAV $varDiv="&"; } } // If any action is performed if($getVars["action"] || $getVars["UPDATE_x"] || $getVars["DELETE_x"]) { if($getVars["UPDATE_x"] && !$getVars["action"])$getVars["action"]="UPDATE"; if($getVars["DELETE_x"] && !$getVars["action"])$getVars["action"]="DELETE"; switch($getVars["action"]) { case "ADD": if($getVars["qty"]>0)addtoBasket($getVars["SCode"], $getVars["qty"], $getVars["price"]); break; case "UPDATE": updateProd(0, $getVars["SCode"], $getVars["qty"], false); break; case "DELETE": delProd($getVars["SCode"]); break; case "KILL": killBasket(); } } updateShipping($sessions["shippingID"]); ?> Link to comment https://forums.phpfreaks.com/topic/212423-url-not-being-generated/#findComment-1106769 Share on other sites More sharing options...
laanes Posted September 3, 2010 Author Share Posted September 3, 2010 When I enter the URL straight into the browser then the new generated URL displays rootURL + rootURL/filename.php like so: http://www.lock-tech.co.uk/index.php?myURL=http://www.lock-tech.co.uk/groups.php and outputs these errors: Notice: Undefined variable: getVars in /home/swansea3/public_html/lock-tech.co.uk/scrptz/sessions.php on line 15 Notice: Undefined index: vat in /home/swansea3/public_html/lock-tech.co.uk/scrptz/sessions.php on line 39 Notice: Undefined index: action in /home/swansea3/public_html/lock-tech.co.uk/scrptz/sessions.php on line 62 Notice: Undefined index: UPDATE_x in /home/swansea3/public_html/lock-tech.co.uk/scrptz/sessions.php on line 62 Notice: Undefined index: DELETE_x in /home/swansea3/public_html/lock-tech.co.uk/scrptz/sessions.php on line 62 Notice: Undefined index: page in /home/swansea3/public_html/lock-tech.co.uk/groups.php on line 6 Notice: Undefined index: prodg in /home/swansea3/public_html/lock-tech.co.uk/groups.php on line 11 Notice: Undefined index: prodg in /home/swansea3/public_html/lock-tech.co.uk/groups.php on line 16 Link to comment https://forums.phpfreaks.com/topic/212423-url-not-being-generated/#findComment-1106799 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.