Jump to content

[SOLVED] Simple form extraction.. or so i thought....


will_1990

Recommended Posts

<?php
$one_way= isset($_POST['one_way'])?$_POST['one_way']:null; // make sure value is available first.
   
   //To protect MySQL injection
     $flight_route_out = stripslashes($flight_route_out);
      $flight_route_return = stripslashes($flight_route_return);
      $flight_route_out = mysql_real_escape_string($flight_route_out);
      $flight_route_return = mysql_real_escape_string($flight_route_return);
   
   //Queries
     $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route` = '$flight_route_out'";
     //$sql="SELECT * FROM $tbl_name1 WHERE flight_route_return='$flight_route_return'";
   
   //Execute  query  1
     $result = mysql_query($sql1);

    if (mysql_error()) {
    $message  = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $sql1;
    die($message);
                 }
             
   while ($row = mysql_fetch_assoc($result)) {
    echo $row['flight_route_out']; // removed the $
    echo $row['flight_route_return']; // removed the $
   }         
   

   mysql_free_result($result);   
     
?>

 

Commented what I fixed.

Link to comment
Share on other sites

  • Replies 87
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Go ahead with Premiso's, but if you please can try this with his script

 

Add your mysql connection to the top, and tell me if the mysql_num_rows returns 0 or not

 

<?php
$one_way= isset($_POST['one_way'])?$_POST['one_way']:null; // make sure value is available first.
   
   //To protect MySQL injection
     $flight_route_out = stripslashes($flight_route_out);
      $flight_route_return = stripslashes($flight_route_return);
      $flight_route_out = mysql_real_escape_string($flight_route_out);
      $flight_route_return = mysql_real_escape_string($flight_route_return);
   
   //Queries
     $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route` = '$flight_route_out'";
     //$sql="SELECT * FROM $tbl_name1 WHERE flight_route_return='$flight_route_return'";
   
   //Execute  query  1
     $result = mysql_query($sql1) or die(mysql_error());

 echo mysql_num_rows($result);
             
   while ($row = mysql_fetch_assoc($result)) {
    echo $row['flight_route_out']; // removed the $
    echo $row['flight_route_return']; // removed the $
   }         
   

   mysql_free_result($result);   
     
?>

 

Link to comment
Share on other sites

phpSensei just used what you had but left my database connection at the top

 

here is what was returned loads of connection errors

 

Test Post Data

Array
(
    [flight_route_out] => Bristol - Newcastle
    [departure_date] => 26/12/2008
    [flight_route_return] => Bristol - Newcastle
    [return_date] => 29/12/2008
    [num_of_pass] => 1
    [submit] => Submit
)

End Test Post Data
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /nas/students/w/wbennett/unix/public_html/webair/booking.php on line 21

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /nas/students/w/wbennett/unix/public_html/webair/booking.php on line 21

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /nas/students/w/wbennett/unix/public_html/webair/booking.php on line 22

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /nas/students/w/wbennett/unix/public_html/webair/booking.php on line 22

Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /nas/students/w/wbennett/unix/public_html/webair/booking.php on line 29

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /nas/students/w/wbennett/unix/public_html/webair/booking.php on line 29
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (/code]

ta

Link to comment
Share on other sites

phpSensei just used what you had but left my database connection at the top

 

here is what was returned loads of connection errors

 

Test Post Data

Array
(
    [flight_route_out] => Bristol - Newcastle
    [departure_date] => 26/12/2008
    [flight_route_return] => Bristol - Newcastle
    [return_date] => 29/12/2008
    [num_of_pass] => 1
    [submit] => Submit
)

End Test Post Data
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /nas/students/w/wbennett/unix/public_html/webair/booking.php on line 21

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /nas/students/w/wbennett/unix/public_html/webair/booking.php on line 21

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /nas/students/w/wbennett/unix/public_html/webair/booking.php on line 22

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /nas/students/w/wbennett/unix/public_html/webair/booking.php on line 22

Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /nas/students/w/wbennett/unix/public_html/webair/booking.php on line 29

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /nas/students/w/wbennett/unix/public_html/webair/booking.php on line 29
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (/code]

ta

 

Here is the latest php code

 

<?php
ini_set("display_errors", 1);
error_reporting(E_ALL);

echo "Test Post Data <pre>";
print_r($_POST);
echo "</pre>End Test Post Data";

    //database inforamtion
      $host="stocks"; // Host name
      $username="wbennett"; // Mysql username
      $password="mysql5"; // Mysql password
      $db_name="wbennett"; // Database name
      $tbl_name1="flight_webair";
     
$one_way= isset($_POST['one_way'])?$_POST['one_way']:null; // make sure value is available first.
   
   //To protect MySQL injection
     $flight_route_out = stripslashes($flight_route_out);
      $flight_route_return = stripslashes($flight_route_return);
      $flight_route_out = mysql_real_escape_string($flight_route_out);
      $flight_route_return = mysql_real_escape_string($flight_route_return);
   
   //Queries
     $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route` = '$flight_route_out'";
     //$sql="SELECT * FROM $tbl_name1 WHERE flight_route_return='$flight_route_return'";
   
   //Execute  query  1
     $result = mysql_query($sql1) or die(mysql_error());
    
    echo mysql_num_rows($result);
             
   while ($row = mysql_fetch_assoc($result)) {
    echo $row['flight_route_out']; // removed the $
    echo $row['flight_route_return']; // removed the $
   }         
   

   mysql_free_result($result);   
     
?>

Link to comment
Share on other sites

<?php
ini_set("display_errors", 1);
error_reporting(E_ALL);

    //database inforamtion
      $host="stocks"; // Host name
      $username="wbennett"; // Mysql username
      $password="mysql5"; // Mysql password
      $db_name="wbennett"; // Database name
      $tbl_name1="flight_webair";
    // Connect to server and select databse.

      mysql_connect("$host", "$username", "$password")or die("cannot connect");
      mysql_select_db("$db_name")or die("cannot select DB");   

 

You still need the mysql_connection

Link to comment
Share on other sites

<?php
ini_set("display_errors", 1);
error_reporting(E_ALL);

    //database inforamtion
      $host="stocks"; // Host name
      $username="wbennett"; // Mysql username
      $password="mysql5"; // Mysql password
      $db_name="wbennett"; // Database name
      $tbl_name1="flight_webair";
    // Connect to server and select databse.

      mysql_connect("$host", "$username", "$password")or die("cannot connect");
      mysql_select_db("$db_name")or die("cannot select DB");   

 

You still need the mysql_connection

 

Did he remove it?

Link to comment
Share on other sites

not sure what to do as this exactly the same database connection is working with my user logon script

<?php
$host="stocks"; // Host name
$username="wbennett"; // Mysql username
$password="mysql5"; // Mysql password
$db_name="wbennett"; // Database name
$tbl_name="staff_webair"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

// username and password sent from form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];

// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);

$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row

if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
header("location:staff.php");
}
else {
echo "Wrong Username or Password";
}
?>

 

can you spot any differences with the logon? it was working before :S

Link to comment
Share on other sites

<?php
ini_set("display_errors", 1);
error_reporting(E_ALL);

    //database inforamtion
      $host="stocks"; // Host name
      $username="wbennett"; // Mysql username
      $password="mysql5"; // Mysql password
      $db_name="wbennett"; // Database name
      $tbl_name1="flight_webair";
    // Connect to server and select databse.

      mysql_connect("$host", "$username", "$password")or die("cannot connect");
      mysql_select_db("$db_name")or die("cannot select DB");   

 

You still need the mysql_connection

 

Did he remove it?

 

no its still there...

Link to comment
Share on other sites

umm try this, you removed the mysql_connect portion out of the code thus no sql connection would be found.

 

<?php
ini_set("display_errors", 1);
error_reporting(E_ALL);

    //database inforamtion
      $host="stocks"; // Host name
      $username="wbennett"; // Mysql username
      $password="mysql5"; // Mysql password
      $db_name="wbennett"; // Database name
      $tbl_name1="flight_webair";

mysql_connect("$host", "$username", "$password")or die("cannot connect");
      mysql_select_db("$db_name")or die("cannot select DB");        

$one_way= isset($_POST['one_way'])?$_POST['one_way']:null; // make sure value is available first.
   
   //To protect MySQL injection
     $flight_route_out = stripslashes($flight_route_out);
      $flight_route_return = stripslashes($flight_route_return);
      $flight_route_out = mysql_real_escape_string($flight_route_out);
      $flight_route_return = mysql_real_escape_string($flight_route_return);
   
   //Queries
     $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route` = '$flight_route_out'";
     //$sql="SELECT * FROM $tbl_name1 WHERE flight_route_return='$flight_route_return'";
   
   //Execute  query  1
     $result = mysql_query($sql1) or die(mysql_error());
    
    echo mysql_num_rows($result);
             
   while ($row = mysql_fetch_assoc($result)) {
    echo $row['flight_route_out']; // removed the $
    echo $row['flight_route_return']; // removed the $
   }         
   

   mysql_free_result($result);   
     
?>

 

If it was there, what errors if it giving you?

Link to comment
Share on other sites

Okay please try this (removed the error display part):

 

and if it works, tell me what the mysql_num_rows says

 

<?php
$host="stocks"; // Host name
$username="wbennett"; // Mysql username
$password="mysql5"; // Mysql password
$db_name="wbennett"; // Database name
$tbl_name="staff_webair"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

$one_way= isset($_POST['one_way'])?$_POST['one_way'] : NULL; // make sure value is available first.
   
   //To protect MySQL injection
     $flight_route_out = stripslashes($flight_route_out);
      $flight_route_return = stripslashes($flight_route_return);
      $flight_route_out = mysql_real_escape_string($flight_route_out);
      $flight_route_return = mysql_real_escape_string($flight_route_return);
   
   //Queries
     $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route` = '$flight_route_out'";
     //$sql="SELECT * FROM $tbl_name1 WHERE flight_route_return='$flight_route_return'";
   
   //Execute  query  1
     $result = mysql_query($sql1) or die(mysql_error());

 echo mysql_num_rows($result);
             
   while ($row = mysql_fetch_assoc($result)) {
    echo $row['flight_route_out']; // removed the $
    echo $row['flight_route_return']; // removed the $
   }         
   

   mysql_free_result($result);   
     

Link to comment
Share on other sites

umm try this, you removed the mysql_connect portion out of the code thus no sql connection would be found.

 

<?php
ini_set("display_errors", 1);
error_reporting(E_ALL);

    //database inforamtion
      $host="stocks"; // Host name
      $username="wbennett"; // Mysql username
      $password="mysql5"; // Mysql password
      $db_name="wbennett"; // Database name
      $tbl_name1="flight_webair";

mysql_connect("$host", "$username", "$password")or die("cannot connect");
      mysql_select_db("$db_name")or die("cannot select DB");        

$one_way= isset($_POST['one_way'])?$_POST['one_way']:null; // make sure value is available first.
   
   //To protect MySQL injection
     $flight_route_out = stripslashes($flight_route_out);
      $flight_route_return = stripslashes($flight_route_return);
      $flight_route_out = mysql_real_escape_string($flight_route_out);
      $flight_route_return = mysql_real_escape_string($flight_route_return);
   
   //Queries
     $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route` = '$flight_route_out'";
     //$sql="SELECT * FROM $tbl_name1 WHERE flight_route_return='$flight_route_return'";
   
   //Execute  query  1
     $result = mysql_query($sql1) or die(mysql_error());
    
    echo mysql_num_rows($result);
             
   while ($row = mysql_fetch_assoc($result)) {
    echo $row['flight_route_out']; // removed the $
    echo $row['flight_route_return']; // removed the $
   }         
   

   mysql_free_result($result);   
     
?>

 

If it was there, what errors if it giving you?

 

right tried this now back to this error

 

Test Post Data

Array
(
    [flight_route_out] => Bristol - Newcastle
    [departure_date] => dd/mm/yy
    [flight_route_return] => Bristol - Newcastle
    [return_date] => dd/mm/yy
    [num_of_pass] => 1
    [submit] => Submit
)

End Test Post Data1
Notice: Undefined index: flight_route_out in /nas/students/w/wbennett/unix/public_html/webair/booking.php on line 37

Notice: Undefined index: flight_route_return in /nas/students/w/wbennett/unix/public_html/webair/booking.php on line 3

 

with the test stuff still in..

Link to comment
Share on other sites

You keep removing important peices, lol.

 

<?php
ini_set("display_errors", 1);
error_reporting(E_ALL);

    //database inforamtion
      $host="stocks"; // Host name
      $username="wbennett"; // Mysql username
      $password="mysql5"; // Mysql password
      $db_name="wbennett"; // Database name
      $tbl_name1="flight_webair";

mysql_connect("$host", "$username", "$password")or die("cannot connect");
      mysql_select_db("$db_name")or die("cannot select DB");        

      $flight_route_out=$_POST['flight_route_out'];
     $flight_route_return=$_POST['flight_route_return'];
     $date_out=$_POST['departure_date'];
     $date_return=$_POST['return_date'];
     $passenger_num=$_POST['num_of_pass'];
     $one_way= isset($_POST['one_way'])?$_POST['one_way']:null; // make sure value is available first.
   
   //To protect MySQL injection
     $flight_route_out = stripslashes($flight_route_out);
      $flight_route_return = stripslashes($flight_route_return);
      $flight_route_out = mysql_real_escape_string($flight_route_out);
      $flight_route_return = mysql_real_escape_string($flight_route_return);
   
   //Queries
     $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route` = '$flight_route_out'";
     //$sql="SELECT * FROM $tbl_name1 WHERE flight_route_return='$flight_route_return'";
   
   //Execute  query  1
     $result = mysql_query($sql1) or die(mysql_error());
    
    echo mysql_num_rows($result);
             
   while ($row = mysql_fetch_assoc($result)) {
    echo $row['flight_route_out']; // removed the $
    echo $row['flight_route_return']; // removed the $
   }         
   

   mysql_free_result($result);   
     
?>

 

I added the variables be assigned from post back in.

Link to comment
Share on other sites

You keep removing important peices, lol.

 

<?php
ini_set("display_errors", 1);
error_reporting(E_ALL);

    //database inforamtion
      $host="stocks"; // Host name
      $username="wbennett"; // Mysql username
      $password="mysql5"; // Mysql password
      $db_name="wbennett"; // Database name
      $tbl_name1="flight_webair";

mysql_connect("$host", "$username", "$password")or die("cannot connect");
      mysql_select_db("$db_name")or die("cannot select DB");        

      $flight_route_out=$_POST['flight_route_out'];
     $flight_route_return=$_POST['flight_route_return'];
     $date_out=$_POST['departure_date'];
     $date_return=$_POST['return_date'];
     $passenger_num=$_POST['num_of_pass'];
     $one_way= isset($_POST['one_way'])?$_POST['one_way']:null; // make sure value is available first.
   
   //To protect MySQL injection
     $flight_route_out = stripslashes($flight_route_out);
      $flight_route_return = stripslashes($flight_route_return);
      $flight_route_out = mysql_real_escape_string($flight_route_out);
      $flight_route_return = mysql_real_escape_string($flight_route_return);
   
   //Queries
     $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route` = '$flight_route_out'";
     //$sql="SELECT * FROM $tbl_name1 WHERE flight_route_return='$flight_route_return'";
   
   //Execute  query  1
     $result = mysql_query($sql1) or die(mysql_error());
    
    echo mysql_num_rows($result);
             
   while ($row = mysql_fetch_assoc($result)) {
    echo $row['flight_route_out']; // removed the $
    echo $row['flight_route_return']; // removed the $
   }         
   

   mysql_free_result($result);   
     
?>

 

I added the variables be assigned from post back in.

 

where is this?

 

without doing that change when i removed something lol i have now only got the two errors on line 37 and 38 with undefined values.

Link to comment
Share on other sites

lol ok is this waht you want? (i no longer have that test bit in is this ok?)

 

<?php
ini_set("display_errors", 1);
error_reporting(E_ALL);

$one_way= (isset($_POST['one_way'])) ? $_POST['one_way'] : NULL; // make sure value is available first.

    //database inforamtion
      $host="stocks"; // Host name
      $username="wbennett"; // Mysql username
      $password="mysql5"; // Mysql password
      $db_name="wbennett"; // Database name
      $tbl_name1="flight_webair";

mysql_connect("$host", "$username", "$password")or die("cannot connect");
      mysql_select_db("$db_name")or die("cannot select DB");        

      $flight_route_out=$_POST['flight_route_out'];
     $flight_route_return=$_POST['flight_route_return'];
     $date_out=$_POST['departure_date'];
     $date_return=$_POST['return_date'];
     $passenger_num=$_POST['num_of_pass'];
     $one_way= isset($_POST['one_way'])?$_POST['one_way']:null; // make sure value is available first.
   
   //To protect MySQL injection
     $flight_route_out = stripslashes($flight_route_out);
      $flight_route_return = stripslashes($flight_route_return);
      $flight_route_out = mysql_real_escape_string($flight_route_out);
      $flight_route_return = mysql_real_escape_string($flight_route_return);
   
   //Queries
     $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route` = '$flight_route_out'";
     //$sql="SELECT * FROM $tbl_name1 WHERE flight_route_return='$flight_route_return'";
   
   //Execute  query  1
     $result = mysql_query($sql1) or die(mysql_error());
    
    echo mysql_num_rows($result);
             
   while ($row = mysql_fetch_assoc($result)) {
    echo $row['flight_route_out']; // removed the $
    echo $row['flight_route_return']; // removed the $
   }         
   

   mysql_free_result($result);   
     
?>

 

ta

just this now

 

1

Notice: Undefined index: flight_route_out in /nas/students/w/wbennett/unix/public_html/webair/booking.php on line 40

 

Notice: Undefined index: flight_route_return in /nas/students/w/wbennett/unix/public_html/webair/booking.php on line 41

Link to comment
Share on other sites

<?php
    //database inforamtion
      $host="stocks"; // Host name
      $username="wbennett"; // Mysql username
      $password="mysql5"; // Mysql password
      $db_name="wbennett"; // Database name
      $tbl_name1="flight_webair";

mysql_connect("$host", "$username", "$password")or die("cannot connect");
      mysql_select_db("$db_name")or die("cannot select DB");        

      $flight_route_out=isset($$_POST['flight_route_out'])?$_POST['flight_route_out']:null;
     $flight_route_return=isset($_POST['flight_route_return'])?$_POST['flight_route_return']:null;
     $date_out=isset($_POST['departure_date'])?$_POST['departure_date']:null;
     $date_return=isset($_POST['return_date'])?$_POST['return_date']:null;
     $passenger_num=isset($_POST['num_of_pass'])?$_POST['num_of_pass']:null;
     $one_way= isset($_POST['one_way'])?$_POST['one_way']:null; // make sure value is available first.
   
   //To protect MySQL injection
     $flight_route_out = stripslashes($flight_route_out);
      $flight_route_return = stripslashes($flight_route_return);
      $flight_route_out = mysql_real_escape_string($flight_route_out);
      $flight_route_return = mysql_real_escape_string($flight_route_return);
   
   //Queries
     $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route` = '$flight_route_out'";
     //$sql="SELECT * FROM $tbl_name1 WHERE flight_route_return='$flight_route_return'";
   
   //Execute  query  1
     $result = mysql_query($sql1) or die(mysql_error());
    
    echo mysql_num_rows($result);
             
   while ($row = mysql_fetch_assoc($result)) {
    echo $row['flight_route_out']; // removed the $
    echo $row['flight_route_return']; // removed the $
   }         
   

   mysql_free_result($result);   
     
?>

 

Should solve the undefined index (those are not fatal errors but you should check if a variables exists before assigning it.)

Link to comment
Share on other sites

<?php
    //database inforamtion
      $host="stocks"; // Host name
      $username="wbennett"; // Mysql username
      $password="mysql5"; // Mysql password
      $db_name="wbennett"; // Database name
      $tbl_name1="flight_webair";

mysql_connect("$host", "$username", "$password")or die("cannot connect");
      mysql_select_db("$db_name")or die("cannot select DB");        

      $flight_route_out=isset($$_POST['flight_route_out'])?$_POST['flight_route_out']:null;
     $flight_route_return=isset($_POST['flight_route_return'])?$_POST['flight_route_return']:null;
     $date_out=isset($_POST['departure_date'])?$_POST['departure_date']:null;
     $date_return=isset($_POST['return_date'])?$_POST['return_date']:null;
     $passenger_num=isset($_POST['num_of_pass'])?$_POST['num_of_pass']:null;
     $one_way= isset($_POST['one_way'])?$_POST['one_way']:null; // make sure value is available first.
   
   //To protect MySQL injection
     $flight_route_out = stripslashes($flight_route_out);
      $flight_route_return = stripslashes($flight_route_return);
      $flight_route_out = mysql_real_escape_string($flight_route_out);
      $flight_route_return = mysql_real_escape_string($flight_route_return);
   
   //Queries
     $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route` = '$flight_route_out'";
     //$sql="SELECT * FROM $tbl_name1 WHERE flight_route_return='$flight_route_return'";
   
   //Execute  query  1
     $result = mysql_query($sql1) or die(mysql_error());
    
    echo mysql_num_rows($result);
             
   while ($row = mysql_fetch_assoc($result)) {
    echo $row['flight_route_out']; // removed the $
    echo $row['flight_route_return']; // removed the $
   }         
   

   mysql_free_result($result);   
     
?>

 

Should solve the undefined index (those are not fatal errors but you should check if a variables exists before assigning it.)

 

lol it didnt, what do u mean by check?

 

 

Link to comment
Share on other sites

Okay codes being thrown around everywhere here, this is my last shot at this lol.

 

<?php
    
    // Forget this for now ini_set("display_errors", 1);
    // and this error_reporting(E_ALL);

   //database inforamtion
     $host      = "stocks"; // Host name
     $username  = "wbennett"; // Mysql username
     $password  = "mysql5"; // Mysql password
     $db_name   = "wbennett"; // Database name
     $tbl_name1 = "flight_webair";

      mysql_connect("$host", "$username", "$password")or die("cannot connect");
      mysql_select_db("$db_name")or die("cannot select DB"); 
   
   // Variables 
     $flight_route_out    = $_POST['flight_route_out'];
     $flight_route_return = $_POST['flight_route_return'];
     $date_out            = $_POST['departure_date'];
     $date_return         = $_POST['return_date'];
     $passenger_num       = $_POST['num_of_pass'];
     $one_way             = (isset($_POST['one_way'])) ? $_POST['one_way'] : null; // make sure value is available first.

   //To protect MySQL injection
     $flight_route_out = stripslashes($flight_route_out);
     $flight_route_return = stripslashes($flight_route_return);
     $flight_route_out = mysql_real_escape_string($flight_route_out);
     $flight_route_return = mysql_real_escape_string($flight_route_return);
   
   //Queries
     $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route` = '$flight_route_out'";
     //$sql="SELECT * FROM $tbl_name1 WHERE flight_route_return='$flight_route_return'";
   
   //Execute  query  1
     $result = mysql_query($sql1) or die(mysql_error());

  if(mysql_num_rows($result) == 0){ die('NO DATA IN THE TABLES!'); }
             
   while ($row = mysql_fetch_assoc($result)) {
    
    echo 'List of Flights:<br>';
    echo $row['flight_route_out']; // removed the $
    echo $row['flight_route_return']; // removed the $
   
   }         
   

   mysql_free_result($result);   
     
?>

Link to comment
Share on other sites

Okay codes being thrown around everywhere here, this is my last shot at this lol.

 

<?php
    
    ini_set("display_errors", 1);
    error_reporting(E_ALL);

   //database inforamtion
     $host      = "stocks"; // Host name
     $username  = "wbennett"; // Mysql username
     $password  = "mysql5"; // Mysql password
     $db_name   = "wbennett"; // Database name
     $tbl_name1 = "flight_webair";

      mysql_connect("$host", "$username", "$password")or die("cannot connect");
      mysql_select_db("$db_name")or die("cannot select DB"); 
   
   // Variables 
     $flight_route_out    = $_POST['flight_route_out'];
     $flight_route_return = $_POST['flight_route_return'];
     $date_out            = $_POST['departure_date'];
     $date_return         = $_POST['return_date'];
     $passenger_num       = $_POST['num_of_pass'];
     $one_way             = (isset($_POST['one_way'])) ? $_POST['one_way'] : null; // make sure value is available first.

   //To protect MySQL injection
     $flight_route_out = stripslashes($flight_route_out);
     $flight_route_return = stripslashes($flight_route_return);
     $flight_route_out = mysql_real_escape_string($flight_route_out);
     $flight_route_return = mysql_real_escape_string($flight_route_return);
   
   //Queries
     $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route` = '$flight_route_out'";
     //$sql="SELECT * FROM $tbl_name1 WHERE flight_route_return='$flight_route_return'";
   
   //Execute  query  1
     $result = mysql_query($sql1) or die(mysql_error());

  if(mysql_num_rows($result) == 0){ die('NO DATA IN THE TABLES!'); }
             
   while ($row = mysql_fetch_assoc($result)) {
    
    echo 'List of Flights:<br>';
    echo $row['flight_route_out']; // removed the $
    echo $row['flight_route_return']; // removed the $
   
   }         
   

   mysql_free_result($result);   
     
?>

 

it is kinda a fatal error though cause i need it to display all of what it picks up from the table (so i would extend the echo $row stuff to output every column from the table. Do i not need the

 

"$one_way= (isset($_POST['one_way'])) ? $_POST['one_way'] : NULL; // make sure value is available first."

Link to comment
Share on other sites

Okay codes being thrown around everywhere here, this is my last shot at this lol.

 

<?php
    
    ini_set("display_errors", 1);
    error_reporting(E_ALL);

   //database inforamtion
     $host      = "stocks"; // Host name
     $username  = "wbennett"; // Mysql username
     $password  = "mysql5"; // Mysql password
     $db_name   = "wbennett"; // Database name
     $tbl_name1 = "flight_webair";

      mysql_connect("$host", "$username", "$password")or die("cannot connect");
      mysql_select_db("$db_name")or die("cannot select DB"); 
   
   // Variables 
     $flight_route_out    = $_POST['flight_route_out'];
     $flight_route_return = $_POST['flight_route_return'];
     $date_out            = $_POST['departure_date'];
     $date_return         = $_POST['return_date'];
     $passenger_num       = $_POST['num_of_pass'];
     $one_way             = (isset($_POST['one_way'])) ? $_POST['one_way'] : null; // make sure value is available first.

   //To protect MySQL injection
     $flight_route_out = stripslashes($flight_route_out);
     $flight_route_return = stripslashes($flight_route_return);
     $flight_route_out = mysql_real_escape_string($flight_route_out);
     $flight_route_return = mysql_real_escape_string($flight_route_return);
   
   //Queries
     $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route` = '$flight_route_out'";
     //$sql="SELECT * FROM $tbl_name1 WHERE flight_route_return='$flight_route_return'";
   
   //Execute  query  1
     $result = mysql_query($sql1) or die(mysql_error());

  if(mysql_num_rows($result) == 0){ die('NO DATA IN THE TABLES!'); }
             
   while ($row = mysql_fetch_assoc($result)) {
    
    echo 'List of Flights:<br>';
    echo $row['flight_route_out']; // removed the $
    echo $row['flight_route_return']; // removed the $
   
   }         
   

   mysql_free_result($result);   
     
?>

 

it is kinda a fatal error though cause i need it to display all of what it picks up from the table (so i would extend the echo $row stuff to output every column from the table. Do i not need the

 

"$one_way= (isset($_POST['one_way'])) ? $_POST['one_way'] : NULL; // make sure value is available first."

 

 

 

So it does return the value 1, how do i move on from this..

 

edit

 

right so now it says list flight out almost done apart from that damn "non fatal error" which seems pretty fatal cause it cant find the flight information.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


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