PHP - Help With Relative / Absolute Address
Hope 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 Similar TutorialsI 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); 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 I have a form with PHP validation and also a mysqli query checking for duplicates in the database for mailing address and email address in mysql.
It works fine but the customers are adding spaces in the mailing address for example 111 mailing address A V E, 1 1 1 ma iling address A V E etc. and my sql query doesn't see that as an address that's a duplicate.
Their alslo adding email address like my@emailaddress.com and m.y@emailaddress.com, m.y.2@emailaddress.com etc to bypass that comparision also.
Is there anyway to stop this from happening?
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 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! Okay, so I know how to get an IP address using $_SERVER['REMOTE_ADDR'], however, I need to get an IP a little different. How would I get the IP of the visitor on a remote site loading MY site using file_get_contents()? It just returns that remote websites server IP... :/ Thanks! Hey guys, is there any way to get the IP address of people accessing my website using PHP? I'm trying to get a statistics area to work for my website. If there isn't a way using PHP, what would be an application which can get the IP address? Thanks a lot, Noid Hello, Please let me know what is the wrong with the following lines of code. I am trying to find the MAC Address of the user who is logging. When I am running the code in localhost it is working. But the same code is not working when I upload it in the server. <?php function getMac(){ exec("ipconfig /all", $output); foreach($output as $line){ if (preg_match("/(.*)Physical Address(.*)/", $line)){ $mac = $line; $mac = str_replace("Physical Address. . . . . . . . . :","",$mac); } } return $mac; } $mac = getMac(); $mac = trim($mac); echo $mac; ?> Please help. Thanks a lot in advance. Regards & Thanks. I have problem with # char in address and jquery, or any address with #. When i put this code in my php: <a href="#" id="dialog_link" class="ui-state-default ui-corner-all"><span class="ui-icon ui-icon-newwin"></span>Open Dialog</a> .. my link on that button is still same like link that i am on it, it do not add "#" in address, but if i, instead of href="#", put href="#some_text", that link shows nice, link.php#some_text, but without text in # it doesn't work :S Why is that happening, and how can i fix that? I need to find a way to resolve a relative path outside the document root, in a cross-platform friendly manner. My users have a settings page where they are able to set the path to a folder where files should be included. This path may not exist at the time of saving the setting. The given path is then retrieved from the database when files are being saved, the path is checked to see if a folder needs to be created, and the file is saved to the path. Two possible paths they may use a * files (This is the webpath: http://site.com/files or absolute path /home/user/public_html/files) * ../files (This is the absolute path: /home/user/files where the webroot is /home/user/public_html/) The first path is easy to deal with. However, I'm having a rough time resolving the second path into a usable system path (i.e. /home/user/files). This needs to be cross platform compatible (windows/'Nix). I've played around with realpath(), but I'm just not finding something that works for me. Any suggestions? I'm kind of a beginner in PHP and I'm not sure how complicated is this thing I need to do so I just need a little bit of help. Anyway, I have this clock counter on a few of my pages, counting down to 0 and what I need to do is execute certain code 15 minutes before a counter reaches 0. It's basically the same code but it needs to run every time one of the counters is 15 minutes away from 0. Any simple way for me to achieve this? Thanks! I know how to get an ip adress from a domain by using gethostbyname(), but I wanted to know if it was possible to get the domain name from the ip address. As in a website address (example.com) has a ip address of xxx.xx.xxx.xxx What I am trying to do is to get the 'example.com' domain name from the ip address. Is this at all possible, if so, how can it be done? Thanks in advance for any that helps out. Hello i just spent my hour finding way to get XML attribute using PHP via URL i wanted to know is it possible or not like http://myurl.com/index.php?$xml=link1 link1 in my XML is some text can we get attribute like this via using URL on address bar Code: [Select] <?xml version="1.0" encoding="ISO-8859-1"?> <note> <link1>www.2advanced.com</link1> <link2>www.hotmail.com</link2> <link3>www.gmail.com</link3> <link4>www.twitter.com</link4> </note> Hi, I have a second website under the same domain www.lucyeleanorbrown.com/weddings.html which I wanted to change to www.weddings.lucyeleanorbrown.com, I have been looking around for PHP for this but am unsure of what to search for, could anyone give me a suggestion? Thank you I would get the ip address of the user that is on the site. I used $ip = $_SERVER['REMOTE_ADDR']; and it doesn't show my actual ip. Is it because im using an apache server on my computer. |