Jump to content

nitrus

Members
  • Posts

    9
  • Joined

  • Last visited

nitrus's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I wasn't exactly sure how to use GET with curl that is probably why I'm using the post field value in curl. If i just append them like you stated it wont be dynamically changing after the user searches the next airport code right? It will only display that one airport in the phx code. How would i change this code, so it will dynamically change by which airport code is typed in or selected in the drop down?
  2. I am trying to add a request header that is generated when a user searches an airport code in the form using weather.com. I have successfully curled the first page, but i am not sure how to implement the next step on using the GET form data. The query string is search?where=phx&start_with=1&search_loc_type=9&x=5&y=13. The phx is the airport code. This changes everytime someone searches a different airport code I am trying to figure out how to add this query string, for example, search?where="Airport_variable".&start_with=1&search_loc_type=9&x=5&y=13. So when a person types a airport code its fetched by the weather.com server and added to the search query and displaying the search results based on that query. What is confusing me is GET request using curl. The current code will parse the airport weather page, but i can't figure out how to add the missing object. Can someone please help me? Here is what I have so far: <?php $URL = "http://www.weather.com/activities/travel/businesstraveler/"; $chwnd = curl_init(); curl_setopt($chwnd, CURLOPT_URL,$URL); curl_setopt($chwnd, CURLOPT_VERBOSE, 1); curl_setopt($chwnd, CURLOPT_POST, 1); curl_setopt($chwnd, CURLOPT_POSTFIELDS, TRUE); $returned = curl_exec($chwnd); curl_close ($chwnd); // /search?where=bhm&start_with=1&search_loc_type=9&x=0&y=0 ?> I am not sure what to do next so i can make a variable that stores that changing airport code on the end of the query string. If i use the search box here is teh following query string http://www.weather.com/outlook/travel/businesstraveler/search?where=phx&start_with=1&search_loc_type=9&x=0&y=0 If i use the drop down its this: http://www.weather.com/outlook/travel/businesstraveler/airportprofile/ANC Where the "ANC" changes. My over all outcome is to display the weather after the drop down or search is request by the get form data.
  3. Ok thanks ill see if anything can help me out. I'm looking for api that fetch airport weather tho. I will surely take a look!
  4. Is the a another website that i could use for testing purposes? I was also thinking of using Regular expression to fetch data from the html tags would that be better idea?
  5. Hello PHP Freaks Forums, I am trying to construct a web app to fetch weather off "http://www.flightstats.com", and look up the airport code and display weather for that airport code in that location. I have some code i started writting that has few errors i need help fixing. The code fetches weather off of the flightstats.com, but i need to figure out how i could make a drop down box or form that a user can type a airport code and fetch the weather from flight stats or if you have better website that works better please feel free to suggest it. Thanks. There is error in line three. <?php $airport_code = $_GET["airport"];; function get_string_between($string, $start, $end) { $string = " ".$string; $ini = strpos($string,$start); if ($ini == 0) return ""; $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini; return substr($string,$ini,$len); } $data = file_get_contents("http://www.flightstats.com/go/Airport/weather.do?airportCode=".$airport_code.""); $weatherdiv = get_string_between($data, '<table width="237" class="contentTable">', '</table>'); $weathertext = strip_tags($weatherdiv); ?> <table width="237" class="contentTable"> <?php echo $weathertext; ?> </table>
  6. <html> <body> <h2>Stock </h2> <?php //$ticker = "goog"; if (isset($_GET['get_quote'])) { $ticker = $_GET['ticker']; } $open = fopen("http://download.finance.yahoo.com/d/quotes.csv?s=$ticker&f=sl1d1t1c1ohgv&e=.csv", "r"); $quote = fread($open, 1000); fclose($open); $quote = str_replace("\"", "", $quote); $quote = explode(",", $quote); $stock_0 = ($quote[0]); $stock_1 = ($quote[1]); $stock_2 = ($quote[2]); $stock_3 = ($quote[3]); $sotck_4 = ($quote[4]); $stock_5 = ($quote[5]); echo "Company: <b>$stock_0</b><br>"; echo "Last trade: <b>$stock_1</b><br>"; echo "Date: <b>$stock_2</b><br>"; echo "Time: <b>$stock_3</b><br>"; echo "High: <b>$sotck_4</b><br>"; echo "Low: <b>$stock_5</b><br>"; ?> <br><br> <form action="stockfetch.php" method="get"> Enter Quote: <input type="text" size="10" maxlength="10" name="ticker"/> <input type="submit" value="Enter Quote" name="get_quote" /> </form> </body> </html> Can you help me resolve the fix the "Undefined offset on line 1-5" i can't seem to figure out how to fix that error? When i enter in symbol such as goog it retrieves the right stock information from the csv, but when i first load my stock fetcher it has problems? When i type in other symbols it seems to yooh it comes with n/a but google seems to work.
  7. Its werid i get those errors only on Xampp, so i decided to port my projects to free web hoster where i can store all my projects and display the results. It seem to show no errors vs using xampp it does. I think xampp might have some minor problems and might not have the correct php settings. Thanks for helping me you have been very helpful. I will try to the suggestion you stated! I'll let you know how it goes! Not sure what you mean Christian F. ?
  8. Thanks for helping me out i can't really see the results, since im recieving : line 58 Undefined variable: correct & line 59 Undefined variable : wrong when the submit correct button is pressed. I also recieve a undefiend index variable on line 47 on the main page. I have had these errors alot and the only way i have fixed them as set the variable ass isset($_POST['correct'] for example. I'm not sure if that is the correct way to fix that. Please help. Also i was trying to get the Submit correct button to output the total answers correct and the total answers wrong. It might be XAMPP im running on my machine it always give me undefined index variable errors. Would that be a setting the error reporting that needs to be changed in the php.ini file?
  9. Hello PHPFreaks forum, I am strugging to figure out, how to create a button that stops the rand problem generation and output the users score of correct answers. Right now it only checks if the answers are right and says correct or if its wrong it display the correct answer. I was thinking i need to turn my random varibles into $_SESSION variables, so it stores the users data and then i can echo it back to the user. I am not sure how to this can you please help me. I have been working on this for week now and i am stuck! <html> <head> <?php session_start() ?> <title>Second Grade Math quiz</title> </head> <body id="body"> <div id="wrapper"> <div id="header">Mutiple:</div> <div id="quizbox"> <?php $value1 = rand (1,10); $value2 = rand (1,20); ?> <form action="mathq.php" method="post"> <input type="text" name="input1a" value="<?php echo $value1; ?>" class="value" /> <input type="text" value="x" class="equa" /> <input type="text" name="input2a" value="<?php echo $value2; ?>" class="value" /> <input type="text" value="=" class="equa" /> <input id="answer" type="text" name="answer" value="" class="answer" /><br /><br /> <input type="submit" value="Submit answer" class="submit"> <INPUT TYPE="RESET" VALUE="Clear all fields of this form"> </form> <?php if(isset($_POST['input1a']) && isset($_POST['input2a']) && isset($_POST['answer'])) { $result = $_POST['answer']; $input1a = $_POST['input1a']; $input2a = $_POST['input2a']; if (!empty($input1a) && !empty ($input2a) && !empty($result)) { //echo '<span class="success">Success! '; } if ($result == $input1a * $input2a) { print($input1a . ' x ' . $input2a . ' = ' . '<span class="correct">' . $result . '</span>' . '<br />Correct!'); } else { print($input1a . ' x ' . $input2a . ' = ' . '<span class="incorrect">' . $result . '</span>' . '<br />Wrong!<br /> The correct answer was: ' . '<span class="correct">' . $input1a * $input2a . '</span>'); } } ?> </div> </div> </body> </html>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.