premiso Posted December 10, 2008 Share Posted December 10, 2008 <?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. Quote Link to comment https://forums.phpfreaks.com/topic/136420-solved-simple-form-extraction-or-so-i-thought/page/2/#findComment-711955 Share on other sites More sharing options...
will_1990 Posted December 10, 2008 Author Share Posted December 10, 2008 shall i update my php with premiso suggestions but leave the error checking and test stuff in?.. edit: Ill put that in after the database connection as it doesnt have it included.. Quote Link to comment https://forums.phpfreaks.com/topic/136420-solved-simple-form-extraction-or-so-i-thought/page/2/#findComment-711958 Share on other sites More sharing options...
phpSensei Posted December 10, 2008 Share Posted December 10, 2008 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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/136420-solved-simple-form-extraction-or-so-i-thought/page/2/#findComment-711960 Share on other sites More sharing options...
premiso Posted December 10, 2008 Share Posted December 10, 2008 shall i update my php with premiso suggestions but leave the error checking and test stuff in? Keep the error checking for now, you can remove the print test array stuff though. Quote Link to comment https://forums.phpfreaks.com/topic/136420-solved-simple-form-extraction-or-so-i-thought/page/2/#findComment-711963 Share on other sites More sharing options...
will_1990 Posted December 10, 2008 Author Share Posted December 10, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/136420-solved-simple-form-extraction-or-so-i-thought/page/2/#findComment-711969 Share on other sites More sharing options...
will_1990 Posted December 10, 2008 Author Share Posted December 10, 2008 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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/136420-solved-simple-form-extraction-or-so-i-thought/page/2/#findComment-711972 Share on other sites More sharing options...
phpSensei Posted December 10, 2008 Share Posted December 10, 2008 Your mysql connection is not working, I think thats the problem, does this connection work elsewhere? Quote Link to comment https://forums.phpfreaks.com/topic/136420-solved-simple-form-extraction-or-so-i-thought/page/2/#findComment-711973 Share on other sites More sharing options...
premiso Posted December 10, 2008 Share Posted December 10, 2008 <?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 Quote Link to comment https://forums.phpfreaks.com/topic/136420-solved-simple-form-extraction-or-so-i-thought/page/2/#findComment-711974 Share on other sites More sharing options...
phpSensei Posted December 10, 2008 Share Posted December 10, 2008 <?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? Quote Link to comment https://forums.phpfreaks.com/topic/136420-solved-simple-form-extraction-or-so-i-thought/page/2/#findComment-711977 Share on other sites More sharing options...
will_1990 Posted December 10, 2008 Author Share Posted December 10, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/136420-solved-simple-form-extraction-or-so-i-thought/page/2/#findComment-711978 Share on other sites More sharing options...
will_1990 Posted December 10, 2008 Author Share Posted December 10, 2008 <?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... Quote Link to comment https://forums.phpfreaks.com/topic/136420-solved-simple-form-extraction-or-so-i-thought/page/2/#findComment-711980 Share on other sites More sharing options...
premiso Posted December 10, 2008 Share Posted December 10, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/136420-solved-simple-form-extraction-or-so-i-thought/page/2/#findComment-711982 Share on other sites More sharing options...
phpSensei Posted December 10, 2008 Share Posted December 10, 2008 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); Quote Link to comment https://forums.phpfreaks.com/topic/136420-solved-simple-form-extraction-or-so-i-thought/page/2/#findComment-711984 Share on other sites More sharing options...
will_1990 Posted December 10, 2008 Author Share Posted December 10, 2008 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.. Quote Link to comment https://forums.phpfreaks.com/topic/136420-solved-simple-form-extraction-or-so-i-thought/page/2/#findComment-711987 Share on other sites More sharing options...
phpSensei Posted December 10, 2008 Share Posted December 10, 2008 change $one_way= isset($_POST['one_way'])?$_POST['one_way'] : NULL; // make sure value is available first. to $one_way= (isset($_POST['one_way'])) ? $_POST['one_way'] : NULL; // make sure value is available first. Use the code below, but change the $one_way Quote Link to comment https://forums.phpfreaks.com/topic/136420-solved-simple-form-extraction-or-so-i-thought/page/2/#findComment-711989 Share on other sites More sharing options...
premiso Posted December 10, 2008 Share Posted December 10, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/136420-solved-simple-form-extraction-or-so-i-thought/page/2/#findComment-711991 Share on other sites More sharing options...
phpSensei Posted December 10, 2008 Share Posted December 10, 2008 Oh sorry I was editing in dreamweaver and hadnt notice LOL Quote Link to comment https://forums.phpfreaks.com/topic/136420-solved-simple-form-extraction-or-so-i-thought/page/2/#findComment-711995 Share on other sites More sharing options...
will_1990 Posted December 10, 2008 Author Share Posted December 10, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/136420-solved-simple-form-extraction-or-so-i-thought/page/2/#findComment-711997 Share on other sites More sharing options...
will_1990 Posted December 10, 2008 Author Share Posted December 10, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/136420-solved-simple-form-extraction-or-so-i-thought/page/2/#findComment-711998 Share on other sites More sharing options...
premiso Posted December 10, 2008 Share Posted December 10, 2008 <?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.) Quote Link to comment https://forums.phpfreaks.com/topic/136420-solved-simple-form-extraction-or-so-i-thought/page/2/#findComment-712000 Share on other sites More sharing options...
will_1990 Posted December 10, 2008 Author Share Posted December 10, 2008 <?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? Quote Link to comment https://forums.phpfreaks.com/topic/136420-solved-simple-form-extraction-or-so-i-thought/page/2/#findComment-712001 Share on other sites More sharing options...
phpSensei Posted December 10, 2008 Share Posted December 10, 2008 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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/136420-solved-simple-form-extraction-or-so-i-thought/page/2/#findComment-712002 Share on other sites More sharing options...
will_1990 Posted December 10, 2008 Author Share Posted December 10, 2008 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." Quote Link to comment https://forums.phpfreaks.com/topic/136420-solved-simple-form-extraction-or-so-i-thought/page/2/#findComment-712005 Share on other sites More sharing options...
will_1990 Posted December 10, 2008 Author Share Posted December 10, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/136420-solved-simple-form-extraction-or-so-i-thought/page/2/#findComment-712008 Share on other sites More sharing options...
phpSensei Posted December 10, 2008 Share Posted December 10, 2008 Remove the $one_way if you don't need it. Oh I posted something I edited before change <?php if(mysql_num_rows($result) == 0){ die('NO DATA IN THE TABLES!'); } ?> to <?php echo mysql_num_rows($result); ?> Quote Link to comment https://forums.phpfreaks.com/topic/136420-solved-simple-form-extraction-or-so-i-thought/page/2/#findComment-712012 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.