Jump to content

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


will_1990

Recommended Posts

  • Replies 87
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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:

 

my.php?image=flightwebairsl0.jpg

my.php?image=flightwebairdatakb7.jpg

 

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

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
)

 

??

 

 

Link to comment
Share on other sites

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'";

 

 

Link to comment
Share on other sites

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!!

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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 $
   }  

Link to comment
Share on other sites

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"

Link to comment
Share on other sites

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'

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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!!

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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!

 

 

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.