PHP - Relative V Absolute Location
I am trying to load an xml file but I can't seem to find the location to load it.
Here is the location of the xml file: C:\inetpub\wwwroot\php\webphp.xml Here is the location of the file trying to load the xml: C:\inetpub\wwwroot\php\gui\guiindex.php What location would I put in he $xml = new SimpleXMLElement("XMLFILELOCATION", NULL, true); Similar TutorialsHope this goes here. I run php5 apache 2.2 with mysql4 on my local machine I prefer relative addresses. Can someone help with the correct syntax to call... say.. the Home page (index.php) in the root directory with something like <a href="../" (../ takes me back too far) when called internally At the moment I have to stipulate eg. <a href=index.php> etc Cheers Brian This topic has been moved to CSS Help. http://www.phpfreaks.com/forums/index.php?topic=345942.0 Hi, I'm sorry if this has already been posted, a search of the forum didn't turn anything up so i'll ask away. I'm trying to fetch urls from a document on my server and convert them into absolute urls. I can extract them but some of my links use ../ or ./. I think i've solved the ./ one but I can't find anything on getting the url when ../ is used. As an example some urls use ../index.php when in a directory so http://www.example.com/dir/test.php, so a url of ../index.php from here would land the user on http://www.example.com/index.php. At the moment it's landing on http://www.example.com/../index.php. Any ideas? Help would be appreciated I found one post that related to this topic but I want to make sure I understand. If I have a site with the structu /root/ ____pageone.php ____common/ ___________base.php ___________header.php ____inc/ ______constants.inc.php ____admin/ _________login.php and base.php includes: <?php // Include site constants include_once "../inc/constants.inc.php"; ?> and login.php includes: <?php include_once "../common/base.php"; $pageTitle = "Log in"; include_once "../common/header.php"; ?> and pageone.php includes: Code: [Select] <?php include_once "common/base.php"; $pageTitle = "Page One"; include_once "common/header.php"; ?>the login page loads normally, but pageone.php is broken; I get error messages like Quote Warning: include_once(../inc/constants.inc.php) [function.include-once]: failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/rootdirectory/common/base.php on line 10 . From what I understand, PHP doesn't want to include the same files from different relative paths; you either need to use absolute paths or change the directory structure so that the included files are accessed through the exact same relative path. Is this correct? I find that if I move pageone.php to the admin folder and make the relative path the same, it does work. I have to say, I'm leery of using absolute paths; and if I'm understanding this correctly, you're really constrained on how you set up your directory structure. Comments? Given a directory - folder1/subfolder1, I would like to loop through all subdirectories under the given directory and return the file path relative to the given directory. Example: Code: [Select] Given Directory FolderA FolderB SubFolderA SubFolderB SubSubFolderA File1 FolderC the file path for File1 should be FolderB/SubFolderB/SubSubFolderA/ Any ideas? well good moring dear folks - hope you are all right and everythings is fine across the atlantic today i have a question regarding server-paths - and the absolute and relative in a linux-[opensuse 11.4] lampp-system well i just installed something in to my Lampp on openSuse 11.4 while setting up this application - (it is a joomla 1.7.3 ) i wonder how i name the paths public $unicodeslugs = '0'; public $feed_limit = '10'; public $log_path = 'D:\\Xammp\\xampp\\htdocs\\pre1/logs'; public $tmp_path = 'D:\\Xammp\\xampp\\htdocs\\pre1/tmp'; public $lifetime = '15'; public $session_handler = 'database'; what cou you thinks how shoud i name the paths well you see above this was a windows box where the pahts originally were taken from love to hear from you hey guys i know there is various script about to locate user (country, latitude and longitude) by ip...but can anyone suggest a good one which is free please?
thank you
I have a script that runs in the command line. Is it possible to get where the php interpreter file is? I know I have it running from "C:\php\php.exe" but If I give the script to someone else, php.exe may not be there, and it may not even be a windows operating system, so is there any command to get the location of that file? Directory structu /home/~test/public_html/soap/ .../xml/ .../bin/ .../products/browser/ In file /home/~test/public_html/soap/bin/products/browser/test.php, I include another file and call it's function: Code: [Select] require("../../xml/processXML.php"); $xmlData = generateXML(....); In the /home/~test/public_html/soap/xml/processXML.php, I have the following code: Code: [Select] function generateXML() { exec("../bin/code.cur"); } The problem is the exec("../bin/code.cur") fails of the relative path issue. I did a getcwd() before the exec() and it returned /home/~test/public_html/soap/bin/products/browser. I have tried using dirname() and no help. I hope this is clear enought to understand where I am coming from. Thank you. AM ok so i am using relative timestamps on my forum. if a post was created less than 1 hour ago then it will display something like 32 minutes ago. If it was posted more than 1 hour ago it will display "posted today at 10:00pm", or if it was older than 1 day then it will display the absolute time stamp. My question is how do i get them to update automatically like facebook does? i would like to use jquery for this but after searching i cant make heads or tales of any of it. so to sumarise i would like the timestamps to update without having to refresh the page. Thanks I'm trying to put a variable in a header("Location: /?p=$url"); Is this even possible? hi guys , i know with link youll use the name tag to load a location on the page but i need to know how to use it in php. i have a main page with details at the top of page, half way down i have comments and then the user can add comments to them. currently if you click post a comment its ok but i want to load that comment at the top (scrolled down to location) once you click submit to post your comment as it loads the same page again. this is the views as pages loads with the comment box at bottom. this is how i want the same page to load , half where down where the comment is placed. i want it to work the same as a forum , post your message then you see your message at top of page of that thread all thought the message is actually like the 12th post in the board. Hi guys, I am making a simple program which fetches an array of variables on my table. Basically, I want to map the location of a unit which is plugged into a certain location. The layout consists of 40 locations. I'll be representing them using tables. Lets say I have a table with 1 row and 40 columns which portrays the 40 locations. Lets say, collectively all 40 locations are on Area 238. So each location is labeled 238-1 ... 238-40). In my database I have a field called portNumber which has a value of say 238-11. Now I want the code to check all those data entries with the portNumber LIKE 238, and highlight all rows which return a value. Those without value will remain white. Also the highlighted values should check is the field isHistory is set to 0 otherwise, it won't return the value. Here's the code I did so far: Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Location Mapper</title> </head> <body> <table width="800" border="1" align="center" cellpadding="0" cellspacing="0"> <tr> <th colspan="40" scope="col">SCMST 238</th> </tr> <tr> <?php $conn = mysql_connect("localhost", "root", "123456") or die(mysql_error()); mysql_select_db("orderstatus") or die(mysql_error()); $sql = mysql_query("SELECT * FROM superdome WHERE portNumber LIKE '%238%' AND isHistory='0' ORDER BY portNumber ASC") or die(mysql_error()); if(mysql_num_rows($sql) != 0) { echo " <td width=\"20\" height=\"30\" scope=\"row\"> </th> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> <td width=\"20\"> </td> "; } ?> </tr> </table> </body> </html> So if the query for mysql_num_rows return 0, nothing should be highlighted as shown in the pictu but if the query for mysql_num_rows return a value, all values in the array should be highlighted as shown: Location 5 and 40 are highlighted. Really need help on this one... Thanks! How do I find the location of the php executable? Running CentOS, and it's not at /usr/local/bin/php... This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=333173.0 I was wondering if it's possible to retain loaded files and the current error setttings after a
header("Location: xxxx.php")is issued, for example in this: // Start up the session - not used yet but there just in case session_start(1); // Enable the Autoloader and initialise it require_once 'Autoloader.php'; Autoloader::init(); // Check if the application has been installed yet ---------------------------- if(!file_exists('Engine/config.php')){ session_write_close(); header("Location: install/index.php"); die(); }And I get a class not found error when I open the install/index.php session_start(1); // @todo: Disable this in the production version .... I already did this in the main index -- do I have to do this on all pages that may error? error_reporting(E_ALL & ~E_STRICT); ini_set("display_errors",1); // Because we jumped here, we have to reinstall the autoloader -- why? require_once '../Autoloader.php'; Autoloader::init();While I can understand I wouldn't want this if I was firing off to a completely different site, is there anyway to retain the settings within the same server environment or do I have to reset everything as above. I even tried using session in the hope that this would 'remember' but it didn't work. Any thoughts on this function? Basically what it does is take the current users location ($location) and a relative path ($link) and convert it to a valid URL. I do know that this does work on my example, but does anyone have any suggestions on this? Code: [Select] <?php $location = "http://mysite.com/pages/images/docs/myfile.html"; $link = "../../games/game.html"; function resolve_url($current, $link){ $ui = (object)parse_url($current); $domain = $ui->scheme."://".$ui->host; $levelsA = preg_split("/\.\.\//", $link); $levels = 0; foreach($levelsA as $l){ if(empty($l)) $levels++; } $currentA = preg_split("/\//", $current); $length = count($currentA); array_splice($currentA, -$levels - 1); $currentA[] = preg_replace("/\.\.\//", "", $link); return implode("/", $currentA); } echo resolve_url($location, $link); ?> Thanks! this little piece of code doesn't seem to work: Code: [Select] if($rs_teamcheck['team_id'] != $team{ header( "Location: http://domain/page.php" ) ;} If I replace the header location part with an echo the output is fine, so why isn't the redirect working? This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=350642.0 Hi, Im new to all this coding stuff but get by ok with help from the wealth of info on the internet however in this instance i cant solve a PHP redirect issue im having. Ive got a very simple php script to redirect to a secure paypal item link using the header function. header("Location:https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XYX96W3MSFQZ6"); The problem is when the script is called upon in IE it loops endlessly however works perfectly in Chrome, Firefox, Opera and the Andriod stock browser. I originally tried the redirect directly within the meta tag although this failed on all browsers so now i have the meta tag point to this PHP file. (The meta tag is in a script that submits form data and displays a temporary 'redirecting...' page. Has anyone expirenced this problem before or know of ways to fix it for IE? Could it be an issue with security in IE because the paypal link is secure? Any help would be greatly appreciated. |