will_1990 Posted December 10, 2008 Author 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); ?> done thanks a mill Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 10, 2008 Share Posted December 10, 2008 Whats the output lol? Quote Link to comment Share on other sites More sharing options...
will_1990 Posted December 10, 2008 Author Share Posted December 10, 2008 Whats the output lol? 1List of Flights: Notice: Undefined index: flight_route_out in /nas/students/w/wbennett/unix/public_html/webair/booking.php on line 42 Notice: Undefined index: flight_route_return in /nas/students/w/wbennett/unix/public_html/webair/booking.php on line 43 why is it doing thissss thanks guys Quote Link to comment Share on other sites More sharing options...
premiso Posted December 10, 2008 Share Posted December 10, 2008 Post your MySQL table structure. It seems you are calling the columns wrong. Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 10, 2008 Share Posted December 10, 2008 Everything works then Remove ini_set("display_errors", 1); error_reporting(E_ALL); The undefined index is not actually an error, it a problem with the logic you used, still works tho dont worry with that. Now Remove the mysql_num_rows part, and then let me know the output. the errors are gone, the only thing left now is to know why there is no data in your tables. Take a screenshot of your database table or post it here Quote Link to comment Share on other sites More sharing options...
will_1990 Posted December 10, 2008 Author Share Posted December 10, 2008 Everything works then Remove ini_set("display_errors", 1); error_reporting(E_ALL); The undefined index is not actually an error, it a problem with the logic you used, still works tho dont worry with that. Now Remove the mysql_num_rows part, and then let me know the output. the errors are gone, the only thing left now is to know why there is no data in your tables. Take a screenshot of your database table or post it here the output is "List of Flights:" the database pics: http://img228.imageshack.us/my.php?image=flightwebairsl0.jpg http://img267.imageshack.us/my.php?image=flightwebairdatakb7.jpg i want to get the flight data from flight route and both flight_route_out and return use flight_route... Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 10, 2008 Share Posted December 10, 2008 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 ) Okay check your table column 'flight_route' and see if there is data equal to the flight_route_out Because here we say WHERE `flight_route` = '$flight_route_out'"; check if $flight_route_out actually does equal to flight_route Quote Link to comment Share on other sites More sharing options...
will_1990 Posted December 10, 2008 Author Share Posted December 10, 2008 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 ) Okay check your table column 'flight_route' and see if there is data equal to the flight_route_out Because here we say WHERE `flight_route` = '$flight_route_out'"; check if $flight_route_out actually does equal to flight_route Would capitalisation effect it as my input on the form is like "Bristol - Newcastle" where as the equivilant flight route is "BRISTOL - NEWCASTE". Are you saying my 'flight_route' table name actually needs to be 'flight_route_out' to match what i have named the variable value. Would that also mean i need to duplicate 'flight_route' and have flight_route_return aswell as it cant use the same column for both? also do you want me to replace my 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 $ } with 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 ) ?? Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 10, 2008 Share Posted December 10, 2008 What am saying is If this is your database table Id | flight_route 1 | BRISTOLE - NEWCASTE and $flight_route_out doesnt now equal to BRISTOLE - NEWCASTE then you would get no flight_route data. yes Capitalisation matters, in that case change: $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route` = '$flight_route_out'"; to: $sql1="SELECT * FROM `$tbl_name1` WHERE LOWER(`flight_route`) = '$flight_route_out'"; Quote Link to comment Share on other sites More sharing options...
will_1990 Posted December 10, 2008 Author Share Posted December 10, 2008 What am saying is If this is your database table Id | flight_route 1 | BRISTOLE - NEWCASTE and $flight_route_out doesnt now equal to BRISTOLE - NEWCASTE then you would get no flight_route data. yes Capitalisation matters, in that case change: $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route` = '$flight_route_out'"; to: $sql1="SELECT * FROM `$tbl_name1` WHERE LOWER(`flight_route`) = '$flight_route_out'"; This doesnt change anything, i going to quickly change all the entries in my mysql table to match the ones on my index.php and keep the original query and post back whats returned! thanks!! Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 10, 2008 Share Posted December 10, 2008 Im putting the flight_route lower case so it doesnt become case sensitive. I suggest you also put all of you vars to lower case, so both the data in the db and your post vars are lower case. Use strtolower($string) Quote Link to comment Share on other sites More sharing options...
will_1990 Posted December 10, 2008 Author Share Posted December 10, 2008 Right changed that and still get the same output. "1List of Flights:" so this should be correct? http://img213.imageshack.us/my.php?image=matchingvv6.jpg Quote Link to comment Share on other sites More sharing options...
will_1990 Posted December 10, 2008 Author Share Posted December 10, 2008 Im putting the flight_route lower case so it doesnt become case sensitive. I suggest you also put all of you vars to lower case, so both the data in the db and your post vars are lower case. Use strtolower($string) Do you sitll reccomend i do this? if so how do i do this in the php or html? Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 10, 2008 Share Posted December 10, 2008 I want to see if it spits out the flight_route change while ($row = mysql_fetch_assoc($result)) { echo $row['flight_route_out']; // removed the $ echo $row['flight_route_return']; // removed the $ } to while ($row = mysql_fetch_assoc($result)) { echo $row['flight_route']; echo $row['flight_route_out']; // removed the $ echo $row['flight_route_return']; // removed the $ } Quote Link to comment Share on other sites More sharing options...
will_1990 Posted December 10, 2008 Author Share Posted December 10, 2008 I want to see if it spits out the flight_route change while ($row = mysql_fetch_assoc($result)) { echo $row['flight_route_out']; // removed the $ echo $row['flight_route_return']; // removed the $ } to while ($row = mysql_fetch_assoc($result)) { echo $row['flight_route']; echo $row['flight_route_out']; // removed the $ echo $row['flight_route_return']; // removed the $ } RESULT: "1Bristol - Newcastle" Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 10, 2008 Share Posted December 10, 2008 There you go, the problem is that there is no data in the following columns flight_route_out flight_route_return or maybe those two columns dont exist in your table. I cant see the whole table from the post you gave me, also I said to remove the mysql_num_rows part in the script, thats why you keep getting '1' Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 10, 2008 Share Posted December 10, 2008 http://img228.imageshack.us/img228/3228/flightwebairsl0.jpg You dont even have those two columsn lol Quote Link to comment Share on other sites More sharing options...
will_1990 Posted December 10, 2008 Author Share Posted December 10, 2008 hmm but i dont want those rows to be in the database i just want those to be variable names and collect the database from the flight_route col is this possible or is it worth renameing the col? thanks Quote Link to comment Share on other sites More sharing options...
will_1990 Posted December 10, 2008 Author Share Posted December 10, 2008 http://img228.imageshack.us/img228/3228/flightwebairsl0.jpg You dont even have those two columsn lol thats the point i dont want it to collect it from there i want to to collect it from flight_route and then match the variable collected flight_route_out to flight_route not flight_route_out as obv as u noticed it doesnt exist.. have i done this wrong thanks Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 10, 2008 Share Posted December 10, 2008 http://img228.imageshack.us/img228/3228/flightwebairsl0.jpg You dont even have those two columsn lol thats the point i dont want it to collect it from there i want to to collect it from flight_route and then match the variable collected flight_route_out to flight_route not flight_route_out as obv as u noticed it doesnt exist.. have i done this wrong thanks but you were doing this $row['flight_route_out'], $row means $row['choose_column_from_table'].. Collaborate a little more, I don't understand what you are trying to do. edit: Are you trying to seperate the Bristole - Newcastle and make it into two different vars? Quote Link to comment Share on other sites More sharing options...
will_1990 Posted December 10, 2008 Author Share Posted December 10, 2008 http://img228.imageshack.us/img228/3228/flightwebairsl0.jpg You dont even have those two columsn lol thats the point i dont want it to collect it from there i want to to collect it from flight_route and then match the variable collected flight_route_out to flight_route not flight_route_out as obv as u noticed it doesnt exist.. have i done this wrong thanks but you were doing this $row['flight_route_out'], $row means $row['choose_column_from_table'].. Collaborate a little more, I don't understand what you are trying to do. Sorry i feel so stupid... What i am try to do is query the database as see if the variable flight_route_out matches any flight_routes from "flight route". If this is sucessful i then would like to post all the information in the flight_webair table that relates to that query. eg query select * from flight_webair where flight_route = $flight_route_out and then this hopefully would return what it finds in the database "flight_num" (for this flight) bs001 "flight route" bristol - newcastle "Departure Time" 12:00 "Price" £20.00 do you see what i mean. and if no flights are found then i want to put "sorry no flights are found on the date you selected." (date is chosen via a javascipt calander) then after this i want them to confirm there booking (this is all assuming they only selected one waym i would repeat above steps and show flight ino for the return flight if they didnt) if they confirm i want to write script to say that a certain num of seats have been taken, something like this: elect num_of_seats from booking_webair where date = $date and (select flight_num from flight_webair where flight_route = $flight_route_form and (50 - num_of_seats_booked) i would also like to generate a unqie booking number which should be done by the database. not sure if all this is right but do u get the idea. thanks so much for all your time on this!! Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 11, 2008 Share Posted December 11, 2008 No I mean you had it right, you checked if flight_route_out was in flight_route in the first query, so thats why mysql_num_rows outputted 1, but then you tried printing out the flight_route_out from the database which the column didnt exist Quote Link to comment Share on other sites More sharing options...
will_1990 Posted December 11, 2008 Author Share Posted December 11, 2008 No I mean you had it right, you checked if flight_route_out was in flight_route in the first query, so thats why mysql_num_rows outputted 1, but then you tried printing out the flight_route_out from the database which the column didnt exist so i need to put waht the query returns in an array and then print the array? and therefore will get the data im looking for? thanks Quote Link to comment Share on other sites More sharing options...
will_1990 Posted December 11, 2008 Author Share Posted December 11, 2008 great i get it now its printing fine. Do you know if there is a way that i get it to print html dricetly so i dont have to put "echo "bla bla ba" every time. like in perl there is "html_start" This is so i can easily print the results in a table and get it to match my home page... thanks so so so so so much! Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 11, 2008 Share Posted December 11, 2008 Um not sure what you mean, but you can just do if(mysql_num_rows($result) > 0){ // found a flight or two}else{ echo 'sorry, no flights'; } Quote Link to comment 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.