PHP - Trouble With My File Paths
hello,
i cant see why my navigation file path is not working im working on my localhost: http://localhost:8888/djsonrotation my initialize file is located at http://localhost:8888/djsonrotation/includes/initialize.php my navigation code is located at http://localhost:8888/djsonrotation/pages/pageContent/navigation/ddAccordion.php my js is located at http://localhost:8888/djsonrotation/js/ddaccordion.js if i put these on my ddAccordion.php it works Code: [Select] to find my initialize file <?PHP require_once("../../../includes/initialize.php"); ?> to find my js file <script type="text/javascript" src="../../../js/ddaccordion.js"> this is how my initialize file looks Code: [Select] <?PHP defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR); defined('SITE_DOMAIN') ? null : define('SITE_DOMAIN', 'http://localhost/djsonrotation'); defined('SITE_ROOT') ? null : define('SITE_ROOT', $_SERVER['DOCUMENT_ROOT'].DS.'djsonrotation'); defined('LIB_PATH') ? null : define('LIB_PATH', SITE_ROOT.DS.'includes'); defined('ELEMENTS') ? null : define('ELEMENTS', $_SERVER['DOCUMENT_ROOT'].DS.'djsonrotation'.DS.'pages'.DS.'contElements'); the problem is i can't seem to change ../../../ in to a file path like this does not work Code: [Select] <?PHP require_once(include(LIB_PATH.DS."initialize.php")); ?> i tried a couple of different file paths for my js file but they dont work either Code: [Select] <script type="text/javascript" src="<?php include(SITE_DOMAIN.DS."js".DS."ddaccordion.js"); ?>"> or Code: [Select] <script type="text/javascript" src="<?php include(SITE_ROOT.DS."js".DS."ddaccordion.js"); ?>"> i guess i could just use ../../../ but why are the include paths not working ???? thanks Similar TutorialsI have a form that lets a user upload an image, aswell as another file. I want the image to go into the images directory, and the pdf file to go into the PDF directory once uploaded. The names of the files will then be uploaded to the database. At the moment I can get the image to upload to the database and directory, but the PDF is only uploading the name to the database, it is not going into the PDF directory aswell. I'm not sure if there is a way you can do this, I am trying to use "move_uploaded_file()" to physically move the files but not sure if you can use it twice. here is my code, if you can point anything out or where im going wrong that would be great. <?php include "include/conn.php"; include "include/session.php"; ?> <?php // Check to see if the type of file uploaded is a valid image type function is_valid_type($file) { $valid_types = array("image/jpg", "image/jpeg", "image/bmp", "image/gif"); if (in_array($file['type'], $valid_types)) return 1; return 0; } function showContents($array) { echo "<pre>"; print_r($array); echo "</pre>"; } //Target path for image $TARGET_PATH = dirname(__FILE__) . "/images/"; //Target path for PDF files $PDF_TARGET_PATH = dirname(_FILE_) . "/PDF/"; // Get POST variables $image = $_FILES['image']; $pdf = $_FILES['pdf']; $date= date("Y-m-d "); $time = date("H:i:s"); $title = $_POST['title']; $title_escape = mysql_escape_string($title); $title_slashes = stripslashes($title_escape); $content = $_POST['content']; $image['name'] = mysql_real_escape_string($image['name']); $pdf['name'] = mysql_real_escape_string($pdf['name']); //image path $TARGET_PATH .= $image['name']; //PDF path $PDF_TARGET_PATH .= $pdf['file_name']; // Make sure all the fields from the form have inputs if ($image['name'] == "" ) { $_SESSION['error'] = "All fields are required"; header("Location: add_media.php"); exit; } // Verify file is an image if (!is_valid_type($image)) { $_SESSION['error'] = "You must upload a jpeg, gif, or bmp"; header("Location: add_media.php"); exit; } // move file into the directory and the path name into the database / along with the rest of the form fields if (move_uploaded_file($image['tmp_name'], $TARGET_PATH)) { if(move_uploaded_file($pdf['tmp_name'], $PDF_TARGET_PATH)) { $sql = "INSERT INTO media_table(title, text, time, date, image, PDF) VALUES ('" . $title_slashes . "','" . $content . "', '" . $time . "', '" . $date . "', '" . $image['name'] . "', '" . $pdf['name'] . "')"; $result = mysql_query($sql) or die (mysql_error()); header("Location: add_media.php"); exit; } else { print "did not upload"; } } else { $_SESSION['error'] = "Could not upload file. Check read/write persmissions on the directory"; exit; } ?> my directory on my mamp server looks like this; root/website/index.php I also have some files in a folder like this root/website/pages/files.php My include code is this include("functions.php"); When I try to include a file from the 'website' folder from a page in the 'pages' folder. It gives me errors that look like this. Warning: include(functions.php) [function.include]: failed to open stream: No such file or directory in /website/pages/contact.php on line 2 Warning: include() [function.include]: Failed opening 'functions.php' for inclusion (include_path='.:/Applications/MAMP/bin/php5.3/lib/php') in /Applications/MAMP/htdocs/website/pages/contact.php on line 2 That's what it looks like.. I can't get it working. I was under the impression this was a simple thing to do and I'm fairly certain I've done it before, but it isn't working for some reason. Under the root directory of my project I have two subfolders called "inc" and "lib". lib contains third-party scripts for use in my project. The one in question is phpmailer (lib/class.phpmailer.php). Now, in inc I have a file that needs to include PHPMailer. Inside my script in inc I have this: require_once('../lib/class.phpmailer.php'); It errors out saying it can't find it. I thought that was supposed to go down one directory then back up into lib. The file does indeed exist. What am I doing wrong? This seems like a stupidly simple thing... hello. im having trouble getting my images to show my navigation (which i downloaded from http://www.dynamicdrive.com/dynamicindex17/ddaccordionmenu.htm) im pulling in the navigation dynamically. i can get it to show the navigation and css but not the images its quite a long destination url... if i put this code on the ddAccordian.php page it works Code: [Select] <link href="http://localhost:8888/djsonrotation/admin/pages/contElements/Navigation/Vertical/ddAccordion/css/styles.css" rel="stylesheet" type="text/css" /> if i try and shorten the url like below the css works but i get no images Code: [Select] <?PHP require_once("../includes/initialize.php"); ?> <style type="text/css" rel="stylesheet"> <?php include(NAVIGATION.DS."styles.css"); ?> </style> the Quote include(NAVIGATION.... is being created in my initialize file Code: [Select] defined('NAVIGATION') ? null : define('NAVIGATION', $_SERVER['DOCUMENT_ROOT'].DS.'djsonrotation'.DS.'admin'.DS.'pages'.DS.'contElements'.DS.'Navigation'.DS.'Vertical'.DS.'ddAccordion'.DS.'css'); in my css file i have tried all of these (1 at a time) but none work: Code: [Select] background: black url(titlebar.png) repeat-x center left; background: black url(/titlebar.png) repeat-x center left; background: black url(./titlebar.png) repeat-x center left; background: black url(../titlebar.png) repeat-x center left; background: black url(images/titlebar.png) repeat-x center left; background: black url(/images/titlebar.png) repeat-x center left; background: black url(./images/titlebar.png) repeat-x center left; background: black url(../images/titlebar.png) repeat-x center left; my folders are like this /ddAccordion/css/styles.css /ddAccordion/images/ /ddAccordion/js/ /ddAccordion/ddAccordion.php any thoughts. thanks ricky I'm new to the PHP world and trying to work my way through a problem. I've gone down many roads, but can't seem to find the answer. I'm not even sure this is so much a PHP question at this point as a host configuration issue. I'm trying to grab an XML file from a remote server. My first try was to try to shell out a wget as follows: exec("wget -q -O status.xml - http://$username:$password@$hostname:$port/cgi-bin/status.xml",$xmlget,$err); This didn't work. Not a surprise since doing it directly from SSH gave: Connecting to mydomain.com|99.99.99.99|:8080... failed: Connection refused. [Note that the port 8080 above is, I think, key] I've since tried method using both file_get_contents and cURL. Similar results for all. I won't clutter this up with the code unless you ask. It's all very straightforward. [file_get_contents complains 'Connection refused' and curl_error says 'couldn't connect to host']. With all of the methods, I'm able to grab, say, google.com AND a page from mydomain.com (default port 80), just not from port 8080. I've set 'allow_url_fopen = on' in php.ini and in my code for good measure. Also, the XML file that lives at 8080 is retrieved fine through a browser. I'm hosted at GoDaddy on their "deluxe shared linux" plan. Is there something obvious I'm missing that would allow all this to work over port 80, but not 8080? Thanks is advance! Greg Hi, I have the following code which allows a user to enter a name for a mysql column field. Once they have submitted the form they are then redirected back to the form which allows them to enter the name for another mysql column form. When they are returned to the form, I would like the new column field added to the file named userinfo.php The problem is, I need the column field variable entered into the userinfo.php in the following format $newcolumn = $info['newcolumn'] but when I put it like this $stringData = "$newcolumn = $info['newcolumn']"; I get this error Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/tropicsb/public_html/MemberSiteMaker/admin.php on line 398 Code: [Select] // Profile and Application details case "profileFields": session_start(); if(isset($_SESSION['username'])) { $newcolumn = $_GET['newcolumn']; $file = "lib/userinfo.php"; $fh = fopen($file, 'a') or die ("Cant open file"); $stringData = "$newcolumn = $info['newcolumn']"; fwrite($fh, $stringData); fclose($fh); echo "This is the logged in page\n<br>"; ECHO <<<PAGE <form action=admin.php?cmd=addfield&username=admin method=POST> <input type=text name=newcolumn> <input type=submit name=submit> PAGE; } else { echo "This is a failed login"; } break; case "addfield": include_once("data/mysql.php"); $newcolumn = $_POST['newcolumn']; $mysqlPassword = (base64_decode($mysqlpword)); $con = mysql_connect("$localhost", "$mysqlusername", "$mysqlPassword") or die(mysql_error()); mysql_select_db("$dbname", $con) or die(mysql_error()); $result=mysql_query("ALTER TABLE members ADD $newcolumn VARCHAR(30) AFTER approved") or die("Alter Error: ".mysql_error()); mysql_close($con); echo "Database has been modified successfully."; echo '<meta http-equiv="REFRESH" content="5;url=admin.php?cmd=profileFields&username=admin&$newcolumn">'; break; thanks Trying to a. check if dir exists if not create it, and b. save an uploaded file to that directory. Nothing however is working but I'm pulling no errors, heres the code: $test_pic = $_POST['test_pic']; // I've also tried $test_pic = $_FILES["test_pic"]; : with no success if (is_uploaded_file($test_pic)) { if (!file_exists("tests/uploads/" . $test_name . "/")) { $create_test_folder = (mkdir("tests/uploads/" . $test_name)); if (!$create_test_folder) { echo "cant create folder"; die; } } $target_path = ("tests/uploads/" . $test_name . "/" . $test_name . "_1"); if (($_FILES["test_pic"]["type"] == "image/gif") || ($_FILES["test_pic"]["type"] == "image/jpeg") || ($_FILES["test_pic"]["type"] == "image/jpg") || ($_FILES["test_pic"]["type"] == "image/png") && ($_FILES["test_pic"]["size"] < 50000)) { if (!copy($test_pic, $target_path)) { echo "cant copy picture"; die; } } else { echo "file type or size bad"; die; } } and I understand its not at all public-safe but I'm just wanting to get it to work before I throw in the security. Thanks for the help! Hi everyone! Nice to meet/see/read you. This is my first post and it will probably be a lame one so apologies. I'm a pretty good frontend designer and I've always struggled to learn PHP and my new job is forcing it on me so I'm happy in a "throw me in the deep end" kinda way. I am really stuck! I have a single page that is using jquery to scroll my content left and right via the menu (example attached). What I am trying to do is when on the homepage, don't show the "main logo". When on any other link, show it. I immediately thought of an if/else statement but realised I don't know what or how exactly to target since everything is on the same page and the URL doesn't change. Could I target the image title that is the only image on the homepage? So, something like: <?PHP $image_title = 'home'; if (XXXXX($image_title)) { echo "IMAGE"; } else { echo "NO IMAGE"; } ?> I know that's wrong, I put XXX where I feel like something possibly helpful should go. Heh. I'm not asking for someone to write code for me, I'm happy to learn but but I would be very grateful if someone could just guide me to what I need to do and off to Google I will go. I haven't been able to find anything that is like: "if image title equals". Hmm... I hope I can do this with PHP. Thanks again, Linda Hey guys, I have a script that grabs data from a separate .txt file which is used to perform certain actions within a user's account. The data I'm having trouble with is user key which is used to authenticate an http header. An example of what the txt file would hold is this: 360235276 PbI1c5+PGHSshccYd58AklmTgf5u+tbWZplMRYYxFSivRYw4AZhaVNHwADozYZhZhPnXRSV1rmsrhf1td7w6bJbySZmPHLl+hleyz/Ht4iM= 477947328 cXTnFEVP74RWtAgqM5BlwtgW2i9rP/v44oANzwF+yJZ+9mpvaschyo/HaYP1qUXgIK8nK7jy74iSCEHAgpPgPdryzpReM5cbnVDjRw7h9S0= 503724987 XXEJsklZTFaTx8MLjuNIz0S65Sn02rgbHl2sahdReQdadKP39 evIXUoYdr5NyQMWDVE7cRpvn+zJ7mteH7WJzVh0U/sOcSG7kfcuaWpAOfo= The format I have is: account_ID user_key New account on a fresh line. So in my script I have it grabbing the data as so: $User_DataFile = "accountdata.txt"; $AccData = file($User_DataFile, FILE_SKIP_EMPTY_LINES); foreach($AccData as $line_num => $line) { $AccData = explode(" ", htmlspecialchars(str_replace(" "," ",$line))); if(stristr($AccData[1], "\n")) $AccData[1] = substr($AccData[1], 0, strlen($AccData[1])-2); $AccountID = $AccData[0]; $UserKey = $AccData[1]; echo "Account ID: ".$AccountID."<br/>User Key: ".$UserKey."<br/><br/>"; I have it set to simply echo out the data for debugging which is where I noticed that any slashes or plus or equal signs were not included. When run in Apache it returns this: Account ID: 360235276 User Key: PbI1c5+PGHSshccYd58AklmTgf5u+tbWZplMRYYxFSivRYw4AZhaVNHwADozYZhZhPnXRSV1rmsrhf1td7w6bJbySZmPHLl+hleyz/Ht4iM Account ID: 477947328 User Key: cXTnFEVP74RWtAgqM5BlwtgW2i9rP/v44oANzwF+yJZ+9mpvaschyo/HaYP1qUXgIK8nK7jy74iSCEHAgpPgPdryzpReM5cbnVDjRw7h9S0 Account ID: 503724987 User Key: XXEJsklZTFaTx8MLjuNIz0S65Sn02rgbHl2sahdReQdadKP39 evIXUoYdr5NyQMWDVE7cRpvn+zJ7mteH7WJzVh0U/sOcSG7kfcuaWpAOfo So as you can see by comparison there is no slashes or plus or equal signs present, which is going to be a major problem. Is there any way of getting around this problem? Thanks. Hello fellow developers, Let me start by saying I'm still a PHP noob so please don't go too hard on me if I my code reflects this noobishness... So I'm trying to build a (very) simple RSS reader using jQuery and PHP. When the user clicks on an option from a dropdown, an AJAX call is made and passes the url selected from the list to a PHP script. The PHP script then loads the appropriate xml file from an 'xmlcache' folder. Everything is working just fine for files named as such: somefilename_1231231231.xml The problem is that I need it to be able to load files which have been urlencoded such as: http%3A%2F%2Ffeeds.feedburner.com%2Fajaxian_1235523548 In case you're wondering, the numbers at the end are a timestamp which will determine if the reader will load a cached copy of the desired xml file (if it's less than an hour old) or if it needs to get a fresh version (this part of the code is not written yet). Here is a look at my script thus far: <?php $url = "./xmlcache/" . urlencode($_REQUEST['url']); //access url from AJAX call echo $url; //outputs -> "./xmlcache/http%3A%2F%2Ffeeds.feedburner.com%2Fajaxian_1235523548.xml", which is the same as the file's name $curTime = time(); $urlParts = explode('_', $url); $urlTime = intval($urlParts[1]); $diff = $curTime - $urlTime; $urlAge = 60 * 60; //60sec * 60min = 3600sec or 1 hour if(file_exists($url)){ if($diff > $urlAge){ //the > will be switched to < to make logical sense once testing is done. $xml = simplexml_load_file($url); //ROOT TAG foreach($xml as $key0 => $value){ echo "$key0: $value"; foreach($value->attributes() as $attributeskey0 => $attributesvalue1){ echo "$attributeskey0: $attributesvalue1"; } echo "<br />"; //1 LEVEL BELOW ROOT TAG foreach($value as $key => $value2){ echo "$key: $value2"; foreach($value2->attributes() as $attributeskey => $attributesvalue2){ echo "$attributeskey = $attributesvalue2"; } echo '<br />'; //2 LEVELS BELOW ROOT TAG foreach($value2 as $key2 => $value3){ echo "$key2: $value3"; foreach($value3->attributes() as $attributeskey2 => $attributesvalue3){ echo "$attributeskey2 = $attributesvalue3"; } echo '<br />'; //3 LEVELS BELOW ROOT TAG foreach($value3 as $key3 => $value4){ echo "$key3: $value4"; foreach($value4->attributes() as $attributeskey3 => $attributesvalue4){ echo "$attributeskey3 = $attributesvalue4"; } echo '<br />'; //4 LEVELS BELOW ROOT TAG foreach($value4 as $key4 => $value5){ echo "$key4: $value5"; foreach($value5->attributes() as $attributeskey4 => $attributesvalue5){ echo "$attributeskey4 = $attributesvalue5"; } echo '<br />'; //5 LEVELS BELOW ROOT TAG foreach($value5 as $key5 => $value6){ echo "$key5: $value6"; foreach($value6->attributes() as $attributeskey5 => $attributesvalue6){ echo "$attributeskey5 = $attributesvalue6"; } echo '<br />'; } } } } echo '<br />'; } echo '<br />'; } }else{ //need to create the XML file from scratch, do a curl function, or read from a text file echo "need a new version"; //@unlink("$url); } }else{ echo "That file does not exist.<br/>"; } ?> The error message I'm getting is this: Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "./xmlcache/http%3A%2F%2Ffeeds.feedburner.com%2Fajaxian_1235523548.xml" in C:\wamp\www\reader\loadfeed.php on line 13 Warning: Invalid argument supplied for foreach() in C:\wamp\www\reader\loadfeed.php on line 16 The second error is obviously thrown because the file doesn't get loaded. I appreciate any help you gurus have to offer, and if you have any suggestions for the best way to load a fresh version that will be handled by the first else statement, I'm all ears. Thanks guys! I am very new to php and am trying to create a simple application that uploads a PDF file to a database. I have one field for the Volume Number and on file field for the PDF to be uploaded. My issue is i can't get the PDF to upload or insert the name of the pdf (eg volume1.pdf) into the data base. I would also like to point out that I know i have a low post count, but i only seek help when i truly need it and have exhausted all other resources... Here is what i have, please go easy on me this is my first round at php: Code: [Select] <?php if(isset($_POST['submit'])){ $vol_num = $_POST['vol_num']; $pdf = $_FILES['pdf']['name']; $path = '../pdf/'.$_FILES['pdf']['name']; move_uploaded_file($_FILES["pdf"]["tmp_name"], $path); mysql_query("INSERT INTO volumes set vol_num='$vol_num', vol_link='$pdf'") or die (mysql_error()); echo "<script>location.href='add_volume.php'</script>"; } ?> what am i doing wrong here? Thanks in advance Hi. So I've coded many a file upload form and never had any trouble. Until now. For some reason when I try to upload MP3 files, I'll hit submit and the page just reloads. Once it does so, the file upload field is once again blank. What's odd is that images and documents upload just fine. It's only audio tracks that cause the page to reload and clear. My php.ini max file upload size is at this point set to 100M, and the files I'm trying to upload are under 10M. Any ideas? Here's the form code, just to post it-- pretty basic. I'm at a loss here.... Any ideas would be appreciated. Thanks very much. <form action="test.php" enctype="multipart/form-data" method="POST"/> <input type = "file" name = "audio" /> <p><input type ="submit" name="submit" value="do it."/><p> </form> Any help is much appreciated in advance... I have a master file located along the root path that needs to be included in subdomains. Inside the master file are includes like Code: [Select] <?php include("../bodyCopy/anyfile.php"); ?> that need to reference the /bodyCopy directory IN THE SUBDOMAIN and NOT along the root. The problem that I'm having is that the master file resides OUTSIDE of the subdomain on the root (in a '/bodyCopy' directory. How do I write the PHP include so that files included in a subdomain from outside of the subdomain (on root) search directories INSIDE the subdomain and NOT relative to the root path? Here's what I mean. I have this file sitting on the root: /home/xxxx/public_html/constructfiles/filetoinclude.php It needs to be included he /home/xxxx/public_html/SUBDOMAIN/publicfile.php Then, 'filetoinclude.php' needs to include other files that are he /home/xxxx/public_html/SUBDOMAIN/bodyCopy/otherfilestoinclude.php ...but, 'filetoinclude.php' is searching along the root path for '/home/xxxx/public_html/bodyCopy/otherfilestoinclude.php' (which does not exist), and NOT within the SUBDOMAIN for the '/home/xxxx/public_html/SUBDOMAIN/bodyCopy/otherfilestoinclude.php' like I need it to. It appears that PHP will only search along the root path of the included file and NOT the root path of the file in which an include is included. I'm confusing myself now, but I hope someone can help. Thanks, Jet - I would like to better understand relative and absolute paths when rewriting URLs. My virtual host configuration is shown below. I wish the server to see something like: https://example.com?page=page1&controller=controller1&data1=123&data2=321Given the rewrites as shown in my virtual host, what would be the proper URL in the browser? One of these (note the ? and &), or something different? https://example.com/page1/controller1?data1=123&data2=321 https://example.com/page1/controller1&data1=123&data2=321Next, if I enter one of the URLs, how do relative paths to images, etc work? Would the browser think it is in the root directory, or in /page1/controller1? I had problems with relative paths, and changed to absolute paths, and it fixed the problem, but I wish to better understand what is happening. On a side note, I would appreciate any critique of my virtual host configuration. My goal is for all requests to example.com to redirect to https://example.com, for only https://example.com (no subdomain) to redirect to https://www.example.com, and do the rewriting of page and controller. Thank you # Note that if a virtual ServerName is not found (i.e. IP 192.168.1.200), Apache defaults to first virtual host. # Note that if ServerName is set to one of the virtual host ServerName's in the Second Section, it doesn't work (why?) # Handle just example.com to http <VirtualHost *:80> ServerName example.com ServerAlias *.example.com Redirect / https://www.example.com/ </VirtualHost> # Handle just example.com without subdomains <VirtualHost *:443> ServerName example.com # ServerAlias example.com SSLEngine on SSLCipherSuite SSLv3:TLSv1:+HIGH:!SSLv2:!MD5:!MEDIUM:!LOW:!EXP:!ADH:!eNULL:!aNULL SSLCertificateKeyFile /etc/pki/tls/private/example_key.pem SSLCertificateFile /etc/pki/tls/certs/example_startssl.crt SSLCertificateChainFile /etc/pki/tls/certs/sub.class1.server.ca.pem Redirect / https://www.example.com/ </VirtualHost> <VirtualHost *:443> ServerName example.com ServerAlias *.example.com DocumentRoot /var/www/example/html SSLEngine on SSLCipherSuite SSLv3:TLSv1:+HIGH:!SSLv2:!MD5:!MEDIUM:!LOW:!EXP:!ADH:!eNULL:!aNULL SSLCertificateKeyFile /etc/pki/tls/private/example_key.pem SSLCertificateFile /etc/pki/tls/certs/example_startssl.crt SSLCertificateChainFile /etc/pki/tls/certs/sub.class1.server.ca.pem <Directory "/var/www/example/html"> allow from all Options +Indexes <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / # Are these lines necessary, or should I create a virtual host for http on port 80 instead? RewriteCond %{HTTPS} !=on RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [NE,R,L] ## If the request is for a valid directory, file, or link, don't do anything RewriteCond %{REQUEST_FILENAME} -d [OR] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -l RewriteRule ^ - [L] #remove the trailing slash RewriteRule (.+)/$ $1 # If you add this first rule to support views, be sure to remove the QSA flag from the second rule (maybe not required since the first rule has the L flag) #replace mypage/mycontroller with index.php?page=mypage&controller=mycontroller RewriteRule ^([^/]+)/([^/]+)/?$ index.php?page=$1&controller=$2 [L,QSA] #replace mypage with index.php?page=mypage RewriteRule ^([^/]+)/?$ index.php?page=$1 [L,QSA] </IfModule> </Directory> </VirtualHost> Hey everyone, Im writing some code that has to work out a route based on linking airports and output all the flights it takes to get there, tried searching just dont really know what to search for The data table looks like this ID, Origin, Destination, DatetimeDeparting, DatetimeArriving, Price 1, BKK, CNX, 2010-10-14 12:00:00, 2010-10-14 14:00:00, 125 2, STN, BKK, 2010-10-13 18:00:00, 2010-10-13 22:00:00, 300 etc. What is the easiest way of working out the path from STN to CNX via BKK? UPDATE: Just to make it more interesting there will be instances where there is more than 1 path eg. STN -> KUL -> BKK -> CNX This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=348545.0 Hi all, How do I get the following paths from the array separately in a foreach loop? level.dat level.dat_old session.lock uid.data If I use Code: [Select] foreach($outer_dir as $key=>$val) [code] then I get a warning because its returning the folder as 'Array'. The files still upload, as well as a single file called Array. Can i just strip these from the foreach? [code] Array ( [data] => Array ( ) [level.dat] => level.dat [level.dat_old] => level.dat_old [players] => Array ( [herghost.dat] => herghost.dat ) [region] => Array ( [r.-1.0.mcr] => r.-1.0.mcr [r.0.0.mcr] => r.0.0.mcr ) [session.lock] => session.lock [uid.dat] => uid.dat ) herghost.dat Many thanks from a confused user I am using the free web host http://www.byethost2.com/ and need help figuring out where and how to make my php files to?! Currently I have the following Config file... Code: [Select] <?php // Build Date: 2011-12-17 1:15pm // Website Environment define('ENVIRONMENT', 'development'); //define('ENVIRONMENT', 'production'); // Web Root (aka Document Root) (**Physical Location) define('WEB_ROOT', ENVIRONMENT === 'development' ? '/Users/user1/Documents/DEV/++htdocs/05_Debbie/' : '/var/www/vhosts/MySite.com/httpdocs/'); // Base URL (**Virtual Location) define('BASE_URL', ENVIRONMENT === 'development' ? 'http://local.debbie/' : 'http://www.MySite.com/'); ?> What am I supposed to use for WEB_ROOT and BASE_URL on this free hosting site?! Currently, to view my test website you go to... http://www.doubledee.byethost2.com/ I suppose that could be "BASE_URL", but for where things are physically stored so I can redefine "WEB_ROOT" I have no clue... Help! Thanks, Debbie First of all, does anyone know of some good documentation to better understand cookies? I've gone through the PHP manual, and can find how to use PHP to work with cookies, but not how cookies really work.
In particular, it is my understanding that if the domain is .mydomain.com, then mydomain.com, www.mydomain.com, or whatEver.mydomain.com, cookies could be set for each, and available for each, right?
If path was /, cookies will be sent for mydomain.com, mydomain.com/bla, and mydomain.com/bla/bla. If path was /bla, cookies will be not be sent for mydomain.com, but will be sent for mydomain.com and mydomain.com/bla/bla.
Also, what would be the impact if Apache rewrote bla.mydomain.com to mydomain.com/bla?
Please feel free to provide any other insight on this topic.
Thank you
|