Jump to content

monkeypaw201

Members
  • Posts

    376
  • Joined

  • Last visited

Posts posted by monkeypaw201

  1. The code is just posting to same page and nothing happens...

     

    <?php
    if(isset($_FILES['file']))
    {
      if ($_FILES["file"]["error"] > 0)
        {
        echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
        }
      else
        {
        echo "File Uploaded Successfully";
    
        if (file_exists("../downloads/" . $_FILES["file"]["name"]))
          {
          echo $_FILES["file"]["name"] . " already exists. ";
          }
        else
          {
          $filename = date("siHdmY");
          move_uploaded_file($_FILES["file"]["tmp_name"],
          "upload/" . $_FILES["file"]["name"]);
          echo "Stored in: " . "../downloads/" . $filename;
          }
        }
    }else{
    ?>
    <form method="POST" action="upload.php">
    
    <p>Pilot ID:<br>
    <input type="text" name="pilot_id">
    <p>File:<br>
    <input type="file" name="file">
    <p>Title:<br>
    <input type="text" name="title">
    <p>Description:<br>
    <textarea name="description"></textarea>
    <p>Author:<br>
    <input type="text" name="author">
    <p><input type="submit" name="submit" value="Upload File">
    </form>
    <?php
    }
    ?>
    

     

    NOTE: Its not done, but eventually it will insert Title, Author, Description, Pilot ID into database along with $filename.

  2. Here's the logic...

     

    First off, all of this is to decide what a link directs to.

     

    There are 4 Ranks:

    • Regional
    • Short Haul
    • Medium Haul
    • Long Haul

     

    And international certification

     

    And 6 aircraft. Each aircraft has a minimum rank associated to it. (ie Regional is limited to Aircraft A and Aircraft B, and SHort Haul has Aircraft C, D AND the aircraft from Regional cause its a higher rank)

     

    The purpose is to check the pilot's rank and see if they are certified to fly the flight on that page. If they are the link goes to file.php if they aren't it links to details.php and adds what they are missing to the javascript alert popup..

     

    Hope this helps... Does the code you (mjdamato) put work for this logic? Looking at it im not so sure..

     

    Thanks

  3. Can someone please help me clean up this code? I wrote it yet it still gives me headaches everytime i look at it :P

     

    <?php
    if(isset($_SESSION['pilot_id']))
    {
       $pilot = mysql_query("SELECT * FROM `users` WHERE `pilot_id` = '$_SESSION[pilot_id]'");
    
       $row_pilot = mysql_fetch_array($pilot);
       
    if($row_aircraft['rank'] == "Regional" && ($row_pilot['rank'] == "Regional" || $row_pilot['rank'] == "Short Haul" || $row_pilot['rank'] == "Medium Haul" || $row_pilot['rank'] == "Long Haul"))
    {
    $file = "file";
    $rankreq = "1";
    }
    elseif($row_aircraft['rank'] == "Short Haul" && ($row_pilot['rank'] == "Short Haul" || $row_pilot['rank'] == "Medium Haul" || $row_pilot['rank'] == "Long Haul"))
    {
    $file = "file";
    $rankreq = "1";
    }
    elseif($row_aircraft['rank'] == "Medium Haul" && ($row_pilot['rank'] == "Medium Haul" || $row_pilot['rank'] == "Long Haul"))
    {
    $file = "file";
    $rankreq = "1";
    }
    elseif($row_aircraft['rank'] == "Medium Haul" && $row_pilot['rank'] == "Long Haul")
    {
    $file = "file";
    $rankreq = "1";
    }else{
    $file = "details";
    $rankreq = "0";
    }
    
    if($row_route['category'] == "International")
    {
       if($row_pilot['international'] == "Yes")
       {
       $file = "file";
       }else{
       $file = "details";
       $rankintl = "0";
       }
    }else{
    $file = "details";
    }
    
    }
    else
    {
    $file = "details";
    }
    ?>
    
                <td>  <?php
                		if($file == "file")
                		{
                		echo "<a href='file.php?id=" . $row_timetable['id'] . "' ";
                		?>
                		onclick="javascript:return confirm('Are you sure you want to place a bid on this flight?')"
                		<?php
                		echo " ><img src='http://www.cormorantair.com/images/pirep.jpg' hieght='15' width='15'>";
                		}
                		else
                		{
                		echo "<a href='details.php?id=" . $_GET['id'] . "' ";
                		?>
                		onclick="alert('Sorry, It looks like you are not meeting all the requirements to fly this route. The missing requirements are listed below. \n\n <?php if(!isset($_SESSION['pilot_id'])){echo "- You Must Be Logged In";}else{ ?><?php if(!isset($rankreq)){echo "- You Do Not Have A High Enough Rank \n";} ?><?php if(!isset($rankintl)){echo "- You Are Not Certified For International Flights \n";}} ?>')"
                		<?php
                		echo " ><img src='http://www.cormorantair.com/images/pirep.jpg' hieght='15' width='15'>";
                		}
                		?>
    

     

    thx

  4. Ok, so after adding a bit of code I have a new challenge. Users are ranked based on the number of hours they fly, which is calculated every time its requested based on several tables. My problem is I need to allow users to access the file page if they have the minimum rank AND any higher rank.

     

    Its a bit confusing but maybe the code will help

     

     

    <?php
    $rank1 = $row_aircraft['rank'] . "First Officer";
    $rank2 = $row_aircraft['rank'] . "Captain";
    
    if(isset($_SESSION['pilot_id']))
    {
       $pilot = mysql_query("SELECT * FROM `users` WHERE `pilot_id` = '$_SESSION[pilot_id]'");
    
       $row_pilot = mysql_fetch_array($pilot);
       
    if($row_pilot['rank'] == $rank1)
    {
    $file = "file";
    $rankreq = "1";
    }
    elseif($row_pilot['rank'] == $rank1)
    {
    $file = "file";
    $rankreq = "1";
    }else{
    $file = "details";
    }
    
    if($row_route['category'] == "International")
    {
       if($row_pilot['international'] == "Yes")
       {
       $file = "file";
       }else{
       $file = "details";
       $rankintl = "0";
       }
    }else{
    $file = "details";
    }
    
    }
    else
    {
    $file = "details";
    }
    ?>
    
                <td>  <?php
                		if($file == "file")
                		{
                		echo "<a href='file.php?id=" . $row_timetable['id'] . "' ";
                		?>
                		onclick="javascript:return confirm('Are you sure you want to place a bid on this flight?')"
                		<?php
                		echo " ><img src='http://www.cormorantair.com/images/pirep.jpg' hieght='15' width='15'>";
                		}
                		else
                		{
                		echo "<a href='details.php?id=" . $_GET['id'] . "' ";
                		?>
                		onclick="alert('Sorry, It looks like you are not meeting all the requirements to fly this route. The missing requirements are listed below. \n\n <?php if(!isset($_SESSION['pilot_id'])){echo "- You Must Be Logged In";}else{ ?><?php if(!isset($rankreq)){echo "- You Do Not Have A High Enough Rank \n";} ?><?php if(!isset($rankintl)){echo "- You Are Not Certified For International Flights \n";}} ?>')"
                		<?php
                		echo " ><img src='http://www.cormorantair.com/images/pirep.jpg' hieght='15' width='15'>";
                		}
                		?>

     

    kenrbnsn thanks for the rapid reply... I tried modifying your code to meet the new issue, but it seemed harder than to just add a '=1' here and there...hehe

  5. I have the code below but it seems kind-of messy.. is there any way to clean it up? Also, there seems to be an unexpected T_IF error on the indicated line

     

    In the testing scenario I have no PHP SESSION ATM

     

    <?php
    $rank1 = $row_aircraft['rank'] . "First Officer";
    $rank2 = $row_aircraft['rank'] . "Captain";
    
    if(isset($_SESSION['pilot_id']))
    {
       $pilot = mysql_query("SELECT * FROM `users` WHERE `pilot_id` = '$_SESSION[pilot_id]'");
    
       $row_pilot = mysql_fetch_array($pilot)
       
    if($row_pilot['rank'] == $rank1) //Error occurs on this line
    {
    $file = "file";
    }
    elseif($row_pilot['rank'] == $rank1)
    {
    $file = "file";
    }else{
    $file = "details";
    }
    
    if($row_route['category'] == "International")
    {
       if($row_pilot['international'] == "Yes")
       {
       $file = "file";
       }else{
       $file = "details";
       }
    }else{
    $file = "details";
    }
    
    }
    else
    {
    $file = "details";
    }
    ?>
    

  6. output:

     

    ?php $SETTINGS = Array ( "hostname_conn_abrv" => "localhost", //database hostname, usually always localhost "database_conn_abrv" => "name", //database name "username_conn_abrv" => "user", // database username "password_conn_abrv" => "pass" // database ); $conn_abrv = mysql_pconnect($hostname_conn_abrv, $username_conn_abrv, $password_conn_abrv) or trigger_error(mysql_error(),E_USER_ERROR); ?>

    Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/sites/monkeypaw201.com/public_html/vabase/install.php on line 137

     

    Tables Inserted Successfully...

     

    Continue...

  7. data.php

    is throwing same error

     

    <?php 
    $SETTINGS = Array (
    
    $hostname_conn_abrv = "localhost";   //database hostname, usually always localhost
    $database_conn_abrv = "name"; //database name
    $username_conn_abrv = "user"; // database username
    $password_conn_abrv = "pass"; // database 
    
    $conn_abrv = mysql_pconnect($hostname_conn_abrv, $username_conn_abrv, $password_conn_abrv) or trigger_error(mysql_error(),E_USER_ERROR); 
    
    ); 
    ?>

  8. Okay, what line is the error one?

     

    Parse error: syntax error, unexpected ';', expecting ')' in /home/sites/monkeypaw201.com/public_html/vabase/data.php on line 4

     

    It says 4 so i assume line 4 of active code which would be if u could lines

     

    mysql_select_db($database_conn_abrv, $conn_abrv);
    

     

    or this: if you could PHP lines

     

    $parseObj = new parsed();
    

  9. this looks like the problem to me the way the Syntax is being highlighted.

     

    $stringData = "\n" . '$conn_abrv = mysql_pconnect($hostname_conn_abrv, $username_conn_abrv, $password_conn_abrv) or trigger_error(mysql_error(),E_USER_ERROR); 
    
    ' . "\n\n" . '
    
    ); ' . "\n" .  ?>';

     

     

     

    The Data.php file saved just fine...

  10. Here is the entire page:

     

    <?php
    
    // VA Base Installation File
    // Created By Lorenzo Aiello
    // Do NOT Modify This File Unless you REALLY know what you are doing
    
    
    if(isset($_GET['step'])){
    
    
    
    if($_GET['step'] == "2"){
    
    ?>
    
    <form name="form1" method="post" action="install.php?step=3">
    
      <table width="100%" border="0">
    
        <tr>
    
          <td>Database Server (Usually Localhost</td>
    
          <td><label>
    
            <input type="text" name="server" id="server" value="localhost">
    
          </label></td>
    
        </tr>
    
        <tr>
    
          <td>Database Name</td>
    
          <td><label>
    
            <input type="text" name="database" id="database">
    
          </label></td>
    
        </tr>
    
        <tr>
    
          <td>Database Username</td>
    
          <td><label>
    
            <input type="text" name="user" id="user">
    
          </label></td>
    
        </tr>
        <tr>
    
          <td>Database Password</td>
    
          <td><label>
    
            <input type="password" name="pass" id="pass">
    
          </label></td>
    
        </tr>
    
        <tr>
    
          <td> </td>
    
          <td><label>
    
            <input type="submit" name="button" id="button" value="Continue">
    
          </label></td>
    
        </tr>
    
      </table>
    
    </form>
    
    <?php
    
    }
    
    
    if($_GET['step'] == "3"){
    
    echo 'Now creating a configuration file....<br><br>';
    
    $ourFileName = "data.php";
    $ourFileHandle = fopen($ourFileName, 'w') or die("<font color='red'>Error creating file</font>");
    fclose($ourFileHandle);
    
    $myFile = "data.php";
    $fh = fopen($myFile, 'w') or die("<font color='red'>Error Writing to file</font>");
    $stringData = '<?php ' . "\n" . '$SETTINGS = Array (' . "\n\n";
    fwrite($fh, $stringData);
    $stringData = '$hostname_conn_abrv';
    fwrite($fh, $stringData);
    $stringData = ' = "' . $_POST['server'] . '";   //database hostname, usually always localhost' . "\n";
    fwrite($fh, $stringData);
    $stringData = '$database_conn_abrv';
    fwrite($fh, $stringData);
    $stringData = ' = "' . $_POST['database'] . '"; //database name' . "\n";
    fwrite($fh, $stringData);
    $stringData = '$username_conn_abrv';
    fwrite($fh, $stringData);
    $stringData = ' = "' . $_POST['user'] . '"; // database username' . "\n";
    fwrite($fh, $stringData);
    $stringData = '$password_conn_abrv';
    fwrite($fh, $stringData);
    $stringData = ' = "' . $_POST['pass'] . '"; // database ' . "\n";
    fwrite($fh, $stringData);
    $stringData = "\n" . '$conn_abrv = mysql_pconnect($hostname_conn_abrv, $username_conn_abrv, $password_conn_abrv) or trigger_error(mysql_error(),E_USER_ERROR); 
    
    ' . "\n\n" . '
    
    ); ' . "\n" . ' ?>';
    fwrite($fh, $stringData);
    fclose($fh);
    
      
    
    echo "File created successfully, <a href='install.php?step=4'>Continue</a>";
    
    }
    
    
    if($_GET['step'] == "4"){
    
    
    require_once("data.php");
    require_once("install.parse.class.php");
    
    mysql_select_db($database_conn_abrv, $conn_abrv);
    
    
    
    $parseObj = new parsed();
    
    $res = $parseObj->parse("install.sql");
    
    
    
    
    
    echo "<br><b>Tables Inserted Successfully...</b><br><br><a href='install.php?step=5'>Continue...</a>";
    
    }
    
    
    
    if($_GET['step'] == "5"){
    $myFile = "data.php";
    unlink($myFile);
    
    
    echo "Congradulations! You just installed VABase. If you have any issues please let us know. It is necessary for you to delete this file for security purposes.";
    
    }
    
    
    }
    else
    {
    echo "You are about to install VABase...<br><br>Are you sure you wish to continue? <a href='install.php?step=2'>Yes, thats what I'm here for...</a>";
    }
    
    ?>
    

  11. Here is the exerpt causing issues:

     

    if($_GET['step'] == "4"){
    
    
    require_once("data.php");
    require_once("install.parse.class.php");
    
    mysql_select_db($database_conn_abrv, $conn_abrv);
    
    
    
    $parseObj = new parsed();
    
    $res = $parseObj->parse("install.sql");
    
    
    
    
    
    echo "<br><b>Tables Inserted Successfully...</b><br><br><a href='install.php?step=5'>Continue...</a>";
    
    }

     

     

     

    thats the only thing that throws errors when on install.php?step=4

     

    the error is:

     

     

    Parse error: syntax error, unexpected T_VARIABLE in /home/sites/monkeypaw201.com/public_html/vabase/install.php on line 89
  12. i am trying to write to a file... BUT im trying to write PHP code to a file and it doesnt work...

     

    <?php
    $ourFileName = "data.php";
    $ourFileHandle = fopen($ourFileName, 'w') or die("<font color='red'>Error creating file</font>");
    fclose($ourFileHandle);
    
    $myFile = "data.php";
    $fh = fopen($myFile, 'w') or die("<font color='red'>Error Writing to file</font>");
    $stringData = "<?php \n\n$SETTINGS = Array (\n\n";
    fwrite($fh, $stringData);
    $stringData = "$hostname_conn_abrv";
    fwrite($fh, $stringData);
    $stringData = " = " . $_POST['server'] . ";   //database hostname, usually always localhost\n";
    fwrite($fh, $stringData);
    $stringData = "$database_conn_abrv";
    fwrite($fh, $stringData);
    $stringData = " = " . $_POST['database'] . "; //database name\n";
    fwrite($fh, $stringData);
    $stringData = "$username_conn_abrv";
    fwrite($fh, $stringData);
    $stringData = " = " . $_POST['user'] . "; // database username\n";
    fwrite($fh, $stringData);
    $stringData = "$password_conn_abrv";
    fwrite($fh, $stringData);
    $stringData = " = " . $_POST['pass'] . "; // database \n";
    fwrite($fh, $stringData);
    $stringData = "\n$conn_abrv = mysql_pconnect($hostname_conn_abrv, $username_conn_abrv, $password_conn_abrv) or trigger_error(mysql_error(),E_USER_ERROR); 
    
    \n\n
    
    ); \n?>";
    fwrite($fh, $stringData);
    fclose($fh);
    ?>
    

     

    thanks

  13. So i have a form that posts to a page and i want the page to filter the results if needed.... i've posted all the code below.

     

    Thanks!

     

    Form (Works)

    <form id="search" method="get" action="schedule.php">
    
      <table width="100%" border="0">
    
          <tr>
    
            <td><div align="left"><span style="color:#BBB; font-size:75%;">Aircraft</span><br />
    
              </div>
    
                      
    
                      <label>
    
                      
    
              <div align="left">
    
                
    
                        <select name="aircraft" id="aircraft">
    
                        <option value="%">Any</option>
    
                          <?php
    
    				$aircraft = mysql_query("SELECT * FROM `aircraft` ORDER BY `name` ASC");
    
    				while($row_aircraft = mysql_fetch_array($aircraft))
    
    				{
    
    				?>
    
                          <option value="<?php echo $row_aircraft['id']; ?>"><?php echo $row_aircraft['name']; ?></option>
    
                          <?php
    
    				}
    
    				?>
    
                        </select>
    
                </div>
    
                      
    
                      </label>        </td>
    
            <td><div align="right"><span style="color:#BBB; font-size:75%;">Departure</span><br />
    
              </div>
    
                      
    
                      <label>
    
                      
    
              <div align="right">
    
                
    
                        <select name="from" id="from">
    
                        <option value="%">Any</option>
    
                          <?php
    
    				$airports = mysql_query("SELECT * FROM `airports` ORDER BY `city` ASC");
    
    				while($row_airports = mysql_fetch_array($airports))
    
    				{
    
    				?>
    
                          <option value="<?php echo $row_airports['id']; ?>"><?php echo $row_airports['city']; ?> (<?php echo $row_airports['icao']; ?>)</option>
    
                          <?php
    
    				}
    
    				?>
    
                        </select>
    
                </div>
    
                      
    
                      </label>        </td>
    
          </tr>
    
          <tr>
    
            <td><div align="left"><span style="color:#BBB; font-size:75%;">Flight Type</span><br />
    
                  <label>
    
                      <select name="type" id="type">
    
                        <option value="%">Any</option>
    
                        <option value="Regional">Regional</option>
    
                        <option value="Short-Haul">Short-Haul</option>
    
                        <option value="Medium-Haul">Medium-Haul</option>
    
                        <option value="Long-Haul">Long-Haul</option>
    
                    </select>
    
                      </label>
    
            </div></td>
    
            <td><div align="right"><span style="color:#BBB; font-size:75%;">Arrival</span><br />
    
              </div>
    
                      
    
                      <label>
    
                      
    
              <div align="right">
    
                
    
                        <select name="to" id="to">
    
                        <option value="%">Any</option>
    
                          <?php
    
    				$airports = mysql_query("SELECT * FROM `airports` ORDER BY `city` ASC");
    
    				while($row_airports = mysql_fetch_array($airports))
    
    				{
    
    				?>
    
                          <option value="<?php echo $row_airports['id']; ?>"><?php echo $row_airports['city']; ?> (<?php echo $row_airports['icao']; ?>)</option>
    
                          <?php
    
    				}
    
    				?>
    
                        </select>
    
                </div>
    
                      
    
                      </label>        </td>
    
          </tr>
    
      </table>
    
                <p align="center">
    
                  <label>
    
                  <input type="submit" name="button" id="button" value="Search Flights" />
    
                  </label>
    
                </p>
    
    </form>

     

    Search Page (Error "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource" )

    <?php
    
    //relevant code
    $routes = mysql_query("SELECT * FROM `routes` WHERE aircraft = '$_GET[aircraft]' AND from = '$_GET[from]' AND type = '$_GET[to]' AND to = '$_GET[type]' ORDER BY RAND()");
    
    while($row_routes = mysql_fetch_array($routes))
    
    {
    
    ?>
    
    <?php
    
    //Farther down the page
    }
    
    ?>

  14. i have this code that works when i post velocity and time, distance and time, but not velocity and distance

     

    the time is posted in minutes, velocity in miles per hour (outputted in knots) and the distance is in miles...

     

    if you could find out whats wrong, much appreciated

     

    <?php
    if(isset($_GET['time']) | isset($_GET['velocity']) | isset($_GET['distance']))
    {
    
    // Define Variables
    if($_GET['time'] != "")
    $tt = $_GET['time'];
    else
    $tt = "?";
    
    if($_GET['velocity'] != "")
    $v = $_GET['velocity'];
    else
    $v = "?";
    
    if($_GET['distance'] != "")
    $d = $_GET['distance'];
    else
    $d = "?";
    
    $deg = $_GET['degrees'];
    
    //Convert Variables
    if($_GET['time'] != "")
    $t = $tt/60;
    else
    $t = $tt;
    
    // Calculate
    if($d == "?")
    $d = $v*$t;
    elseif($v == "?")
    $v = $d/$t;
    elseif($t == "?")
    $t = $d/$v;
    
    //Convert results
    $dn = round($d);
    $vn = round($v*0.868976242);
    if(isset($_GET['time']))
    $tn = round($tt);
    else
    $tn = round($t*60);
    ?>
    
    Hello, <br><br>
    
    Given the information and selections you provided, the calculations have been made and the generated information is below. <br><br>
    
    Traveling at <b><?php echo $vn; ?> kts</b><br>
    Turning <b><?php echo $deg; ?></b>° degrees<br><br>
    
    Will take you <b><?php echo $tn; ?></b> minutes and <b><?php echo $dn; ?></b> miles
    
    <?php }else{ ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
      <head>
      </head>
      <body><FORM action="aircraft_turn.php" method="GET" enctype="multipart/form-data">
              To calulate a number, enter the two you are not looking for (ie searching: time, provide: speed, distance) 
          <br>
          <br>
          Speed: <INPUT maxlength="3" name="velocity" type="text"> mph<br>
          Time: <INPUT name="time" type="text"> minutes<br>
          Distance: <INPUT name="distance" type="text"> miles<br><br><INPUT type="submit" name="submit" value="Calculate!">
        </FORM>
      </body>
    </html>
    <?php } ?>
    

×
×
  • 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.