PHP - Calculating Flight Paths
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 Similar Tutorials<?php function extractItem(&$array, $itemKey) { $data = array(); foreach($array[$itemKey] as $item) { $Id = $item['Id']; // get the id unset($item['Id']); // remove the id from item array $data[$Id] = $item; // set id as the key } unset($array[$itemKey]); // remove item from array. return $data; // return the new item array } // get the api parametures from setup url $country_code = $_GET['country']; $originplace = $_GET['strtplace']; $destination = $_GET['endplace']; $start_date = $_GET['startdate']; if(isset($_GET['enddate']) && $_GET['enddate']!=""){ $end_date = $_GET['enddate'];} $audult = $_GET['audult']; if(isset($_GET['child']) && $_GET['child']!=""){ $child = $_GET['child'];} if(isset($_GET['infent']) && $_GET['infent']!=""){ $infent = $_GET['infent'];} $class = $_GET['class']; if (!empty($_SERVER['HTTP_CLIENT_IP'])){ $ip=$_SERVER['HTTP_CLIENT_IP'];} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){ $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];} else{$ip=$_SERVER['REMOTE_ADDR'];} $xml = simplexml_load_file("http://www.geoplugin.net/xml.gp?ip=".$ip); $ip_curency = $xml->geoplugin_currencyCode ; $query = "&country=".$country_code; $query .= "¤cy=".$ip_curency; $query .= "&locale=en-GB"; $query .= "&originplace=".$originplace; $query .= "&destinationplace=".$destination; $query .= "&outbounddate=".$start_date; if(isset($end_date) && $end_date!=""){ $query .= "&inbounddate=".$end_date;} $query .= "&adults=".$audult; if(isset($child) && $child!=""){ $query .= "&children=".$child;} if(isset($infent) && $infent!=""){ $query .= "&infants=".$infent;} $query .="&locationschema=iata"; $query .="&cabinclass=".$class; $query .="&pagesize=10"; $apiParamsUrl = "http://partners.api.skyscanner.net/apiservices/pricing/v1.0/".$country_code."?apikey=SECRET".$query.""; $apiParamsStr = parse_url($apiParamsUrl, PHP_URL_QUERY); // get the query string parametures parse_str($apiParamsStr, $apiParamsArray); // parse into an array // the api url. First we need to request for a session $apiSessionUrl = 'http://partners.api.skyscanner.net/apiservices/pricing/v1.0'; //open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch,CURLOPT_URL, $apiSessionUrl); curl_setopt($ch,CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded', 'Accept: application/json')); // make api return json data curl_setopt($ch,CURLOPT_POST, count($apiParamsArray)); // set how many fiels curl_setopt($ch,CURLOPT_POSTFIELDS, $apiParamsStr); // set the fields // caputre the headers curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_HEADER, 1); //execute post $response = curl_exec($ch); // get the headers $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $header = substr($response, 0, $header_size); $body = substr($response, $header_size); //close connection curl_close($ch); // get the api session url preg_match('~Location: ([^\s]+)~', $header, $matches); $apiSessionUrl = $matches[1]; // add on the api key for the session $apiSessionUrl .= '?apiKey=' . $apiParamsArray['apikey']; // get the json data $data = file_get_contents($apiSessionUrl); // decode the json $array = json_decode($data, true); // dump json array printf('<pre>Poll Data %s</pre>', print_r($array, true)); //Itineraries $Agents = extractItem($array, 'Agents'); // get array of agents //... foreach ($array['Itineraries'] as $Itineraries) { foreach($Itineraries['PricingOptions'] as $Option) { echo "<b> Agents: </b> "; // loop over agents for current priceOption foreach($Option['Agents'] as $agentId) { echo $Agents[ $agentId ]['Name']. ', '; // echo the agent name that matches agentId. } echo " <br> price </b>",$Option['Price'] ,"<br />"; } } //Legs foreach ($array['Legs'] as $Leg) { echo "<b> Departure </b> " .$Leg['Departure'], " <br> <b>Arrival </b>",$Leg['Arrival'] ,"<br />"; } //Carriers foreach ($array['Carriers'] as $Carrier) { echo "<b> Name </b> " .$Carrier['Name'], " <br> Image </b>",$Carrier['ImageUrl'] ,"<br />"; } //Places foreach ($array['Places'] as $Place) { echo "<b> Code </b> " .$Place['Code'], " <br> Name </b>",$Place['Name'] ,"<br />"; } ?>Hi professionals I am trying to extract the correct information from a flights API It was working until I added in the function. Now I just see the word Poll Data on my screen is there something I am missing here (code attached) Thanks I need help to get flight schedule from http://www.sriwijayaair.co.id/id but always error using curl to access ssl. here are my code: <?php $headers = array( "User-Agent=Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 GTB7.1 (.NET CLR 3.5.30729)", "Accept=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Language=en-us,en;q=0.5", "Accept-Encoding=gzip,deflate", "Accept-Charset=ISO-8859-1,utf-8;q=0.7,*;q=0.7", "Keep-Alive=1150", "Connection=keep-alive", "Referer=http://www.sriwijayaair.co.id/id", "Cookie=language=in; location=id; dest=home; __utma=260465999.1394002812.1293106375.1293106375.1293106375.1; __utmb=260465999.1.10.1293106375; __utmc=260465999; __utmz=260465999.1293106375.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)", "Content-Type=application/x-www-form-urlencoded", "Content-Length=121", "POSTDATA=isReturn=false&from=CGK&to=MES&departDate1=30-&departDate2=11-2010&adult=1&child=0&infant=0&returndaterange=0&Submit=Cari" ); // do access to sriwijaya air $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, "https://booking.sriwijayaair.co.id/b2c/AvailabilityServlet"); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($curl, CURLOPT_HEADER, 1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_VERBOSE, 1); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($curl, CURLOPT_COOKIEJAR, "cookie.txt"); //curl_setopt($curl, CURLOPT_POSTFIELDS, "isReturn=false&from=CGK&to=MES&departDate1=22&departDate2=01-2011&adult=1&child=0&infant=0&returndaterange=0&Submit=Cari"); $curlData = curl_exec($curl); print_r($curlData); curl_close($curl); ?> any help will be appreciate, thanks 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> 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 - 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 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 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; } ?> 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
I have a directory in public WWW. The files throughout the directory have many PHP includes amongst themselves. For example, the file "registration.php" begins with require('../parameters.php'); The directory is complex, like this:
/Public WWW directory/ How would I do that without breaking all the include paths? (I know the solution is probably a one-liner involving __DIR__ ... but I can't seem to code it so it works). Thank you!!
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 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. Hi guys, Just a quick one - this is more of a bit of a challenge than a problem! I'm pretty good with PHP - I'm definitely not a beginner, but I've come across a problem I've not yet been able to solve satisfactorily. Essentially, I am trying to write a really good, solid OOP library that I can hand out for people to use for CMS-driven websites, and I want to literally just upload some files and have access to some variables... simple enough. But, my snagging point came when I was writing the image library, which handles uploading files and moving them from place to place. These functions as you know usually require an absolute server path - not a relative path and certainly not a URL, so I wanted to place something in my config file that gets the base URL, puts the relative path in one variable (e.g. mysite.com/directory would give /directory) and the server path in another (e.g. mysite.com/directory might give var/www/mysite/www/directory). Now I might just be being foolish and overlooking something, but I've used HTTP_HOST, DOCUMENT_ROOT etc to get this information, but I only want to get the base directory that the application resides in - usually with installed software sure as WordPress you have to specify which directory the files are going to sit in, which I wondered if you could gauge automatically? Any help would be appreciated - I've tried as many clever approaches as I could think of, and the only one I can think of now is setting the variables based on, say, installtion.php since I know the name of the file and where it resides, I can strip out all folders minus the filename, which would give me the root directory, but that seems a little fiddly to me? Someone must have done this before and have a nice clean solution to the problem? I'm at a loss anyway, and I figured it might be a fair challenge to do? Thanks, Luke I am in the process of writing a CMS for a friend that is looking to add a classified section to his site. He will be the only one that will ever use it. I got the code to work with one image when he asked me if I could do it so he could post 6 images for each item. I am unable to figure out how to do this. I was told to do this with a while loop. This is the code that I have written so far. <?php //Check to make sure title is filled in. If not redirects to show_add.php if (!$_POST[title]) { header("Location: show_add.php"); exit; } else { //check and see if a session has started session_start(); } //if session has not been properly started redirects back to the administration menu if ($_SESSION[valid] != "yes") { header("Location: admin_menu.php"); exit; } include('includes/connection.php'); //check and see if the type of uploaded file is an image function is_valid_type($file) { $valid_types = array("image/jpg", "image/jpeg", "image/gif", "image/bmp"); if (in_array($file['type'], $valid_types)) return 1; return 0; } //Set Constants $TARGET_PATH = "/home/content/m/i/k/mikedmartiny/html/db_images/"; $title = $_POST['title']; $year = $_POST['year']; $make = $_POST['make']; $model = $_POST['model']; $descript = $_POST['descript']; $image = $_FILES['image']; //Sanitize the inputs $title = mysql_real_escape_string($title); $year = mysql_real_escape_string($year); $make = mysql_real_escape_string($make); $model = mysql_real_escape_string($model); $descript = mysql_real_escape_string($descript); $image['name'] = mysql_real_escape_string($image['name']); //$target_path full string $TARGET_PATH .= $image['name']; //make sure that all fields from form are filled in if ( $title == "" || $year == "" || $make =="" || $model == "" || $descript == "" || $image['name'] == "") { $_SESSION['error'] = "ALL FIELDS ARE REQUIRED!"; header ("Location: show_add.php"); exit; } //check to make sure it has the right file type if (!is_valid_type($image)){ $_SESSION['error'] = "You must upload a jpeg, gif, or bmp"; header ("Location: show_add.php"); exit; } //check to see if a file with that name exsists if (file_exists($TARGET_PATH)){ $_SESSION['error'] = "A FILE WITH THAT NAME ALL READY EXIST!"; header ("Location: show_add.php"); exit; } //move the image - write path to database while($image <=2) { move_uploaded_file($image['tmp_name'], $TARGET_PATH) } else { // Make sure you chmod the directory to be writeable $_SESSION['error'] = "COULD NOT UPLOAD FILE. CHECK WRITE/REWRITE PERMISSIONS ON THE FILE DIRECTORY!"; header ("Location: show_add.php"); exit; } $sql = "INSERT INTO $table (id, title, year, make, model, descript, image, image_two) VALUES ('', '$_POST[title]', '$_POST[year]', '$_POST[make]', '$_POST[model]', '$_POST[descript]', '" . $image['name'] . "', '" . $image['name'] . "')"; $result = mysql_query($sql) or die ("Could not insert data into DB: " . mysql_error()); ?> I only have it set up to work with 2 images right now. I thought it would be easier to get it to work properly. Then I could just add in the rest of the info later. Any help would be greatly appreciated. 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... 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 Not asking someone to do this for me. Just looking for someone to help me get going, and show me how to do this. Need helping calculating text boxes on a form. I want my form to display the premium of $10,000 health insurance. What I mean by this is that I have a form that involves filling out life insurance information. This is the table I'm basing this off of... Age <=30 #health conditions <=2 $0.90 2 <= #health conditions <=5 $1.20 The number of health conditions is equivalent to the number of check boxes that were checked. Additionally, the following conditions apply: - Men are charged a 5% gender risk - Students receive an 8% discount For example, if you are a 23 year old male student who smokes but has no other risk factors your premium amount per $10,000 would be $0.90 * 1.05 * 0.92 = $0.8694. If you wanted to take out a $150,000 life insurance, your monthly premium would be $13.04 (15 * $0.8694). I'm new to php and haven't really calculated forms before... here is my form codes.... 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> <title>Lab 4</title> </head> <body> <?php ?> <form method="POST" action="lab4form.php"> <label for="first_name">First Name:</label> <input type="text" id="first_name" name="first_name" /><br /> <label for="last_name">Last Name:</label> <input type="text" id="last_name" name="last_name" /><br /> <label for="coverage_amount">Coverage Amount:</label> <input type="text" id="coverage_amount" name="coverage_amount" /><br /> <label for="gender">Gender:</label> <br> <input id="male" type="radio" value="Male" name="gender" /> <label for="male">Male</label> <input id="female" type="radio" value="Female" name="gender" /> <label for="female">Female</label> <br /> <br> <label for="Age">Age:</label> <input type="text" id="age" name="age" /><br /> <br> <label for="health">Health Conditions</label> <br /> <input type="checkbox" name="health" value="Heart Disease" /> <label for="health">Heart Disease</label><br /> <input type="checkbox" name="health" value="Diabetes" /> <label for="health">Diabetes</label><br /> <input type="checkbox" name="health" value="High Blood Pressure" /> <label for="health">High Blood Pressure</label><br /> <input type="checkbox" name="health" value="Smoker" /> <label for="health">Smoker</label><br /> <input type="checkbox" name="health" value="Lung Disease" /> <label for="health">Lung disease</label><br /> <FORM METHOD=POST ACTION="lab4form.php"> <P>Employment Status<BR> <SELECT NAME="employment"> <OPTION VALUE="Unemployed">Unemployed <OPTION VALUE="Full-Time">Full-Time <OPTION VALUE="Part-Time">Part-Time <OPTION VALUE="Student">Student </SELECT><br /> <br> <label for="comments">Comments</label> <input type="text" id="comments" name="comments"/><br /> <br> <input type="submit" value="Add User" name="btn_add" /> </form> </body> </html> I have a form that I will post the code for. In my form I have a few things that need to be filled out.... Age, Gender, Coverage Amount, and Health Conditions. The Health Conditions are 5 check boxes the user can select. Now what I'm trying to do is make it so that when the user hits submit the Age and number of Health Conditions checked off will do this... if # of Health Conditions <=2 and Age is <= 30 then = $0.90 if # of Health Conditions =>2 but <=5 and Age is <= 30 then = $1.20 Then after those are calculated I need these to apply to the code... - Men are charged a 5% gender risk - Students receive an 8% discount Here is a example of what I'm trying to get this to do... If you are a 23 year old male student who smokes but has no other risk factors your premium amount per $10,000 would be $0.90 * 1.05 * 0.92 = $0.8694. If you wanted to take out a $150,000 life insurance, your monthly premium would be $13.04 (15 * $0.8694). I'm doing a life insurance form and these are some of the calculations that need to go into it. I'm not sure how I would code these. If someone could help me get started that would be great. Here is my form code and the display page. 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> <title>Lab 4</title> </head> <body> <?php ?> <form method="POST" action="lab4form.php"> <label for="first_name">First Name:</label> <input type="text" id="first_name" name="first_name" /><br /> <label for="last_name">Last Name:</label> <input type="text" id="last_name" name="last_name" /><br /> <label for="coverage_amount">Coverage Amount:</label> <input type="text" id="coverage_amount" name="coverage_amount" /><br /> <label for="gender">Gender:</label> <br> <input id="male" type="radio" value="Male" name="gender" /> <label for="male">Male</label> <input id="female" type="radio" value="Female" name="gender" /> <label for="female">Female</label> <br /> <br> <label for="Age">Age:</label> <input type="text" id="age" name="age" /><br /> <br> <label for="health">Health Conditions</label> <br /> <input type="checkbox" name="health" value="Heart Disease" /> <label for="health">Heart Disease</label><br /> <input type="checkbox" name="health" value="Diabetes" /> <label for="health">Diabetes</label><br /> <input type="checkbox" name="health" value="High Blood Pressure" /> <label for="health">High Blood Pressure</label><br /> <input type="checkbox" name="health" value="Smoker" /> <label for="health">Smoker</label><br /> <input type="checkbox" name="health" value="Lung Disease" /> <label for="health">Lung disease</label><br /> <FORM METHOD=POST ACTION="lab4form.php"> <P>Employment Status<BR> <SELECT NAME="employment"> <OPTION VALUE="Unemployed">Unemployed <OPTION VALUE="Full-Time">Full-Time <OPTION VALUE="Part-Time">Part-Time <OPTION VALUE="Student">Student </SELECT><br /> <br> <label for="comments">Comments</label> <input type="text" id="comments" name="comments"/><br /> <br> <input type="submit" value="Add User" name="btn_add" /> </form> </body> </html> Display Page 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> <title>Lab4</title> </head> <body> <div id="page"> <div id="main"> <div id="content"> <h2>Life Insurance</h2> <table> <tr> <th>Coverage Amount</th> <th>Name</th> <th>Gender</th> <th>Age</th> <th>Health Conditions</th> <th>Employment Status</th> <th>Comments</th> </tr> <?php $coverage_amount = $_POST['coverage_amount']; $age = $_POST['age']; $health = $_POST['health']; if $age = ?> <tr> <td><?php echo $_POST['coverage_amount'];?></td> <td><?php echo $_POST['first_name'];?></td> <td><?php echo $_POST['gender'];?></td> <td><?php echo $age?></td> <td class="right"><?php echo $_POST['health'];?></td> <td class="right"><?php echo $_POST['employment'];?></td> <td><?php echo $_POST['comments'];?></td> </tr> </table> </div> </div> <div id="footer"></div> </div> </body> </html> I have a timestamp field in my mySQL table and need to check if it's 14 day or older. What's the best way to do this? Any help will be appreciated Hi everyone, I'm trying to add up the current time with a specified amount of seconds and insert it in a database afterwards. When I add say: 500 seconds to the current time it adds a whole lot more and I get a number few thousands higher than I want. Can anyone help me???. Gr Ryflex |