Jump to content

unistake

Members
  • Posts

    445
  • Joined

  • Last visited

Everything posted by unistake

  1. I've just contacted the host provider. should be turned on in 10mins
  2. Ok, at the moment it is just displaying a blank white page and no redirect is happening. The queries fire absolutely fine from what i can see in my database. The code seems to break down at the end of the code on line 84. If the code satisfies the if statement on line 91 the code runs and redirects exactly as it should finishing with the exit on line 128.
  3. Muddy_Funster, The script processes the information as needed however after each $line has been processed in the foreach statement, I want all ending results to redirect to header("Location: members_roster.php");
  4. Thanks, This page is purely a php processing page. The user sends data too it from a previous page, and once that data is processed I want it to redirect.
  5. basically once the script has run through every line, I want it to redirect. How can I do this?
  6. anybody?
  7. Hi guys, I have this script I am running, http://pastebin.com/NR1A03hY, works perfectly and does everything I need it to do. The only thing is the redirect at the bottom of the script does not work if line 40 is true. I think I have a problem with my foreach loop and the if statements in-between. Please can someone check, I have no idea on this one! Edit: in the pastebin the redirect is striked out as i was problem solving it. Of course i would not strike it out once its back working! Thanks
  8. the page loads fine beyond the form however i never get an email either to the receiver or cc. Ill check the md5 threads now
  9. Hi guys, I am trying to create a simple PHP script to send a new password to my users using the script below. I believe it was working however seemed to stop after a few tests. Any ideas why? Thanks $rand_password_md5 = md5($rand_password); $sql = "UPDATE Users SET password = '$rand_password_md5' WHERE username = '$code' AND Base = '$base'"; $result = mysqli_query($cxn,$sql) or die ("Can not change your password in our database."); // the email reply // use wordwrap() if lines are longer than 70 characters $msg = wordwrap($msg,70); // send email $to = $row['Femail']; $subject = "website.com | Password reset requested."; $txt = "Hi ".$row['Ffname'].", Please go back to www.website.com and login with your username ".$row['username']." and new password ".$rand_password.". You can then change your password by going to 'Settings' > 'Personal Settings'.!"; $headers = "From: [email protected]" . "\r\n" . "CC: [email protected]"; mail($to,$subject,$txt,$headers);
  10. Hi all, I am trying to calculate the straight line distance between two points by using their co-ordinates on each row from a mysql db that satisfies the query. It works fine, except the last for loop below calculates $lat[$x+1],$long[$x+1] to have blank fields as they no longer exist in the database therefore i have invalid distances calculated. My goal of this script is to find all the routes a particular day a flight attendant is working, by searching my db, rosters, then gathering the departure and arrival airport from this table. With these airports, I then extract their co-ordinates from the table, airports, and use the function below to calculate the distance. Hope it makes sense what I am trying to do below!! <?php function distance($lat1, $lon1, $lat2, $lon2, $unit) { $theta = $lon1 - $lon2; $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta)); $dist = acos($dist); $dist = rad2deg($dist); $miles = $dist * 60 * 1.1515; $unit = strtoupper($unit); if ($unit == "K") { return ($miles * 1.609344); } else if ($unit == "N") { return ($miles * 0.8684); } else { return $miles; } } $today = '2016-01-04'; $sql = "SELECT * FROM rosters WHERE Code = 'TESTUSER' AND SectorDate = '$today' ORDER BY BeginTime ASC"; $result = mysqli_query($cxn,$sql) or die ("Cant get rosters distance."); $dep = array(); $arr = array(); $lat = array(); $long = array(); while($row=mysqli_fetch_array($result)) { $dep[] = $row['Dep']; $arr[] = $row['Arr']; } echo 'Number of flights: '.count($dep).'<br />'; foreach($dep as $key => $value) { $sql = "SELECT * FROM airports WHERE IATA = '$value'"; $result = mysqli_query($cxn,$sql) or die ("Cant get airport coordinates."); while($row=mysqli_fetch_array($result)) { $lat[] = $row['Latitude']; $long[] = $row['Longitude']; } } $max = count($dep); for ($x = 0; $x <= $max; $x++) { echo $dep[$x].' - '.$arr[$x].'<br />'; echo floor(distance($lat[$x],$long[$x],$lat[$x+1],$long[$x+1], "N")) . "nm<br />"; } ?>
  11. Great explanation! Cheers! Finished code: elseif(is_numeric($duty['Duty'])){ // friend WORKING $starttimes = array(); $finishtimes = array(); $starttimes[] = $duty['BeginTime']; $finishtimes[] = $duty['EndTime']; while($duty=mysqli_fetch_assoc($result2)) { $starttimes[] = $duty['BeginTime']; $finishtimes[] = $duty['EndTime']; }
  12. Hi all, I am trying to echo reset($starttimes) to show the first value in my $starttimes array however i it is only showing the second value in the array and skipping the first i want to echo. The statement I have written is inside a while statement however I am not sure if that is where lies the problem. Please take a look at line 29 here: http://pastebin.com/2KQ7kgy9
  13. Hi all, I am trying to pass 4 variables from one php page to another php page containing a google maps api. The variables I am passing are geo coordinates. at the end I want to show the map on my php page however I am struggling with linking php and javascipt together. This is what I have so far: external function page: http://pastebin.com/NAKHmKxW [PART OF MAIN PHP PAGE] <div class="row"> <?php include_once("function_maps.php"); initMap($latitude, $longitude,$row['Latitude'],$row['Longitude']); ?> </div>
  14. At the top of the page I'd just get the number of counts currently sorted in the db then add one. $count = $row['count']; $new_count = $count + 1; $sql= "UPDATE table SET count = '$new_count' WHERE id='$details'"; $result = mysqli_query($cxn,$sql);
  15. Hi guys, I am trying to make an iframe that contains another website so my users can login to the external website and view a partiicular html table on the external website. Once the user is on that page, I want them to be able to click a button hovering over the iframe that will copy all the html code and send back to my php. With this source code I will use the information in my website. One problem, I think the external website has disabled iframes from getting past the login page. Does anyone have a good idea where to start for this project? Thanks in advance!
  16. Final thing, I am trying to improve my UI by creating a <iframe> with a floating button over the iframe that the user can click. This will then parse all the html code from the website where the html table is contained and will send to my website to include in the mysql db.. Ive tried to find a good tutorial but no luck.
  17. Absolute genius!! Thanks man!
  18. Cheers Ch0cu3r! Works amazingly!! The only thing left is in one case the table might contain one row in the middle as below. The script so far stops once it hits this row. Is there anyway to skip this row and allow the script to run until the end of the table for example? <tr class="row-border-top marked-row "> <td>20 Dec 15, Sun</td> <td>OFF(Z)</td><td>CAD</td> <td>00:00 Z</td> <td>21:00 Z</td> <td></td> </tr> <tr> <td colspan="6" class="break-row">**THE REST OF THIS IS NOT VALID**</td> </tr> <tr class="row-border-top simple-row "> <td>21 Dec 15, Mon</td> <td>OFF(Z)</td> <td>CAD</td> <td>00:00 Z</td> <td>21:00 Z</td> <td></td> </tr> Thanks
  19. An example of the full html page I am trying to parse is here: http://pastebin.com/uLxwaeXM Note, the html layout is an external website!
  20. Also I forgot to mention there are another two html tables in the same page I want to parse. How can I use the code above but select only the table with table id="r"? I tried many things such as: $doc = new DOMDocument(); $doc->loadHTML($html); $xpath = new DOMXPath($doc); // use xpath to find all <tr> tags that has the class "marked-row" $rows = $xpath->query('//table[@id="r"]//*tr[contains(@class,"marked-row")]'); // fill an array with 6 empty values $defaults = array_fill(0, 6, ''); // loop over each row found by xpath foreach($rows as $row) { } thanks!
  21. Thanks Ch0cu3r, So question is now how can I get the html code from a webpage to create the variable $html you created above?
  22. Hi guys, I am trying to handle a html form that users are copying and pasting to a form on my website that contains their schedule for a particular day. Generally the format is the same so I am trying to handle the data with a preg_match however sometimes white spaces or blank fields do not upload to my mysql db correctly. An example of the html code from the html table is below: <tr class="row-border-top marked-row "> <td>13 Dec 15, Sun</td> // always the same format <td>OFF(Z)</td> // can vary to contain [a-zA-Z], numericals, brackets, forward slash and possible whitespaces (no guarantee of how many if they are present) <td>DOZ</td> // only three letter characters, empty, or white spaces <td>: </td> // generally contains a time in format hh:mm however could be a) blank, b) only contain ':', c) contain just blank spaces <td>: </td> // generally contains a time in format hh:mm however could be a) blank, b) only contain ':', c) contain just blank spaces <td></td> // only three letter characters or blank </tr> <tr class="row-border-top marked-row "> <td>12 Dec 15, Sat</td> // another row example <td>B/HOL(Z)</td> <td>DOZ</td> <td>: </td> <td>: </td> <td></td> </tr> <tr class="marked-row "> // another row example <td>8 Dec 15, Tue</td> <td>3329</td> <td>RZS</td> <td>17:20</td> <td>21:55</td> <td>DOZ</td> </tr> so far I have the code as follows: else { if (preg_match("#([^,]+), \w{3}[\s]+(.+?)[\s]+(\w{3})[\s]+(\d\d:\d\d) Z[\s]+(\d\d:\d\d) Z[\s]+(.*)#", $line, $match)) { $code = $_SESSION['Code']; $date = date('d/m/Y', strtotime($match[1])); $sectordate = date('Y/m/d', strtotime($match[1])); $duty = $match[2]; $dep = $match[3]; $begin = $match[4]; $end = $match[5]; $arr = $match[6]; $output .= "<tr><td>{$date}</td><td>{$duty}</td><td>{$dep}</td><td>{$begin}</td><td>{$end}</td><td>{$arr}</td></tr>\n"; $addedon = date('Y-m-d H:i:s'); $today = date('Y-m-d'); $sql= "INSERT INTO table (RostersID,Code,Ffname,Fuid,SectorDate,Duty,Dep,BeginTime,EndTime,Arr,AddedOn,Random) VALUES('','$code','{$_SESSION['FULLNAME']}','{$_SESSION['FBID']}','$sectordate','$duty','$dep','$begin','$end','$arr','$addedon','$random')"; $result = mysqli_query($cxn,$sql) or die ("Can not upload the new roster!"); $sql = "SELECT * FROM table WHERE Code = '$code' AND Random !='$random'"; $result = mysqli_query($cxn,$sql) or die ("Can not find the old roster duties to delete then update with the new."); while($row=mysqli_fetch_assoc($result)) { $sql1 = "DELETE FROM table WHERE SectorDate='$sectordate' AND Code='$code' AND Random !='$random'"; $result1 = mysqli_query($cxn,$sql1) or die ("Can't execute!"); } } }
  23. Thanks Requinix, Makes great sense! I had a problem when it came to thinking about the number of cycles 'k' and didnt know the best way to do this, I was thinking making the difference of dates as a percentage and ignoring the number of cycles that would come before the decimal point. I'll post the script when I make it up later today Cheers
  24. Hi Requinix, Thanks for your post. You are absolutely right in your logic and a much better explanation than mine! I'm just stuck putting this maths in to php!
  25. Hi guys, I'm trying to calculate where a future date runs in a 15 day cycle pattern, and then if the day lands on day 13 or 15 of the cycle pattern I want to do something with the result. For example: $pattern = 15; $start_date = strtotime("2015-12-14"); // day 1 // Day 15 = 2015-12-29 $chosen_date = strtotime("2016-03-30"); $difference = ($chosen_date - $start_date) / 83400; // Find which Day the 'chosen_date' comes in the sequence and... If($chosen_date == 13 || $chosen_date == 15) { Echo 'possible outcome. Day $chosen_date."; } Else { Echo 'not possible, day $chosen_date'; } Hope it makes sense! Cheers
×
×
  • 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.