aian04 Posted October 3, 2007 Share Posted October 3, 2007 <html> <head> <link href="interface design/css.css" rel="stylesheet" type="text/css"> </head> <body class="bg"> <?php $datein=$_POST['check-in-date']; $dayin=$_POST['check-in-day']; $r_tpe=$_POST['r_category']; $pac=$_POST['special']; $checkin = "$datein-$dayin" ; $nyt=$_POST['nyts']; $room= mysql_query("SELECT r_no FROM room WHERE r_no ='$r_type'")or die(mysql_error()); $id=$_COOKIE['ID']; mysql_connect('localhost', 'root', 'tmc') or die(mysql_error()); mysql_select_db('tgp') or die(mysql_error()); e //ive got error here in this line if(!mysql_query ("INSERT INTO reservation VALUES ('0','$checkin', '$nyt', '$room', '$pac', '$id')")) { print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">'; print '<b>reservation failed</b>'; print '</div>'; } else { print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">'; print 'Your Information has been successfully added to the database.'; print '<br><br>'; $result=mysql_insert_id(); print "Your Reservation No. is <b>$result</b>"; print '</div>'; } mysql_close(); ?> </body> </html> ok.. again.. here's the question im trying to validate the reservation forms in my reservation table i got res _id checkin date nyt per stay room no package id and Cid which i get the Cid from cookie when dey login Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/ Share on other sites More sharing options...
aian04 Posted October 3, 2007 Author Share Posted October 3, 2007 ok in my database ders many r_no which correspond in $r_type my question is how to choose one... i mean how to do auto select. bcoz if i execute the query SELECT r_no FROM room WHERE r_no ='$r_type'" it will give 3 r_no how to choose one only Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/#findComment-360973 Share on other sites More sharing options...
MmmVomit Posted October 3, 2007 Share Posted October 3, 2007 I can't make heads or tails of anything you've posted. You're using variables that don't exist and trying to execute queries before you've connected to the database. Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/#findComment-361006 Share on other sites More sharing options...
trq Posted October 3, 2007 Share Posted October 3, 2007 One thing I see is a typo here... $r_tpe=$_POST['r_category']; Shouldn't that be? $r_type=$_POST['r_category']; Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/#findComment-361011 Share on other sites More sharing options...
MadTechie Posted October 3, 2007 Share Posted October 3, 2007 try <html> <head> <link href="interface design/css.css" rel="stylesheet" type="text/css"> </head> <body class="bg"> <?php $datein=$_POST['check-in-date']; $dayin=$_POST['check-in-day']; $r_type=$_POST['r_category']; $pac=$_POST['special']; $checkin = "$datein-$dayin" ; $nyt=$_POST['nyts']; $id=$_COOKIE['ID']; mysql_connect('localhost', 'root', 'tmc') or die(mysql_error()); mysql_select_db('tgp') or die(mysql_error()); $room= mysql_query("SELECT r_no FROM room WHERE r_no ='$r_type'")or die(mysql_error()); $room = $room['r_no']; //ive got error here in this line if(!mysql_query ("INSERT INTO reservation VALUES ('0','$checkin', '$nyt', '$room', '$pac', '$id')")) { print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">'; print '<b>reservation failed</b>'; print '</div>'; } else { print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">'; print 'Your Information has been successfully added to the database.'; print '<br><br>'; $result=mysql_insert_id(); print "Your Reservation No. is <b>$result</b>"; print '</div>'; } mysql_close(); ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/#findComment-361012 Share on other sites More sharing options...
aian04 Posted October 3, 2007 Author Share Posted October 3, 2007 ok.. sori for typo error now i change... my problem is the query SELECT r_no FROM room WHERE r_no ='$r_type' will give me 3 r_no d question is how to do auto select... Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/#findComment-361023 Share on other sites More sharing options...
MadTechie Posted October 3, 2007 Share Posted October 3, 2007 erm.. what? please explain what your trying to do here ? Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/#findComment-361035 Share on other sites More sharing options...
aian04 Posted October 3, 2007 Author Share Posted October 3, 2007 ok sori... SELECT r_no FROM room WHERE r_no ='$r_type' it will give me three r_no ryt... so it cant insert in database bcoz the result in that query has a three item for example the result in column r_no got 1, 2 and 3... my question is... is it possible to auto select in that 3 item.. auto select from 1 2 and 3 so it will succesfully save in database Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/#findComment-361045 Share on other sites More sharing options...
MmmVomit Posted October 3, 2007 Share Posted October 3, 2007 What do you mean by "auto select"? Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/#findComment-361048 Share on other sites More sharing options...
aian04 Posted October 3, 2007 Author Share Posted October 3, 2007 auto select.. it will select one in the three item.. is it possible.. Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/#findComment-361050 Share on other sites More sharing options...
MadTechie Posted October 3, 2007 Share Posted October 3, 2007 if you mean insert first found then try this <html> <head> <link href="interface design/css.css" rel="stylesheet" type="text/css"> </head> <body class="bg"> <?php $datein=$_POST['check-in-date']; $dayin=$_POST['check-in-day']; $r_type=$_POST['r_category']; $pac=$_POST['special']; $checkin = "$datein-$dayin" ; $nyt=$_POST['nyts']; $id=$_COOKIE['ID']; mysql_connect('localhost', 'root', 'tmc') or die(mysql_error()); mysql_select_db('tgp') or die(mysql_error()); $room= mysql_query("SELECT r_no FROM room WHERE r_no ='$r_type'")or die(mysql_error()); $found = false; while ($row = mysql_fetch_assoc($room) || !$found) { $room = $row["r_no"]; //ive got error here in this line if(!mysql_query ("INSERT INTO reservation VALUES ('0','$checkin', '$nyt', '$room', '$pac', '$id')")) { print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">'; print '<b>reservation failed</b>'; print '</div>'; } else { $found = true; print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">'; print 'Your Information has been successfully added to the database.'; print '<br><br>'; $result=mysql_insert_id(); print "Your Reservation No. is <b>$result</b>"; print '</div>'; } } mysql_close(); ?> </body> </html> if you mean insert all 3 <html> <head> <link href="interface design/css.css" rel="stylesheet" type="text/css"> </head> <body class="bg"> <?php $datein=$_POST['check-in-date']; $dayin=$_POST['check-in-day']; $r_type=$_POST['r_category']; $pac=$_POST['special']; $checkin = "$datein-$dayin" ; $nyt=$_POST['nyts']; $id=$_COOKIE['ID']; mysql_connect('localhost', 'root', 'tmc') or die(mysql_error()); mysql_select_db('tgp') or die(mysql_error()); $room= mysql_query("SELECT r_no FROM room WHERE r_no ='$r_type'")or die(mysql_error()); while ($row = mysql_fetch_assoc($room) ) { $room = $row["r_no"]; //ive got error here in this line if(!mysql_query ("INSERT INTO reservation VALUES ('0','$checkin', '$nyt', '$room', '$pac', '$id')")) { print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">'; print '<b>reservation failed</b>'; print '</div>'; } else { print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">'; print 'Your Information has been successfully added to the database.'; print '<br><br>'; $result=mysql_insert_id(); print "Your Reservation No. is <b>$result</b>"; print '</div>'; } } mysql_close(); ?> </body> </html> EDIT updated as a note i think your doing this the wrong way.. to start with Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/#findComment-361051 Share on other sites More sharing options...
MmmVomit Posted October 3, 2007 Share Posted October 3, 2007 auto select.. it will select one in the three item.. is it possible.. Does it matter which one you use? Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/#findComment-361053 Share on other sites More sharing options...
aian04 Posted October 3, 2007 Author Share Posted October 3, 2007 yeh ur ryt insert 1st found.. but i try ur code.. it gives me looping error... the error msg is supplied argument is not valid Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/#findComment-361065 Share on other sites More sharing options...
MadTechie Posted October 3, 2007 Share Posted October 3, 2007 Ah yeah will do that is none are found try this <html> <head> <link href="interface design/css.css" rel="stylesheet" type="text/css"> </head> <body class="bg"> <?php $datein=$_POST['check-in-date']; $dayin=$_POST['check-in-day']; $r_type=$_POST['r_category']; $pac=$_POST['special']; $checkin = "$datein-$dayin" ; $nyt=$_POST['nyts']; $id=$_COOKIE['ID']; mysql_connect('localhost', 'root', 'tmc') or die(mysql_error()); mysql_select_db('tgp') or die(mysql_error()); $room= mysql_query("SELECT r_no FROM room WHERE r_no ='$r_type'")or die(mysql_error()); while ($row = mysql_fetch_assoc($room) ) { $room = $row["r_no"]; //ive got error here in this line if(!mysql_query ("INSERT INTO reservation VALUES ('0','$checkin', '$nyt', '$room', '$pac', '$id')")) { print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">'; print '<b>reservation failed</b>'; print '</div>'; } else { print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">'; print 'Your Information has been successfully added to the database.'; print '<br><br>'; $result=mysql_insert_id(); print "Your Reservation No. is <b>$result</b>"; print '</div>'; break; } } mysql_close(); ?> </body> </html> Techie out, head killing now! Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/#findComment-361073 Share on other sites More sharing options...
aian04 Posted October 3, 2007 Author Share Posted October 3, 2007 i dnt see any result... either error or success... y fetch_assoc not fetch_array? Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/#findComment-361129 Share on other sites More sharing options...
aian04 Posted October 3, 2007 Author Share Posted October 3, 2007 <html> <head> <link href="interface design/css.css" rel="stylesheet" type="text/css"> </head> <body class="bg"> <?php mysql_connect('localhost', 'root', 'tmc') or die(mysql_error()); mysql_select_db('tgp') or die(mysql_error()); $datein=$_POST['check-in-date']; $dayin=$_POST['check-in-day']; $r_type=$_POST['r_category']; $pac=$_POST['special']; $checkin = "$datein-$dayin" ; $nyt=$_POST['nyts']; $room= mysql_query("SELECT r_no FROM room WHERE r_no ='$r_type'")or die(mysql_error()); $id=$_COOKIE['ID']; while ($row = mysql_fetch_assoc($room) ) { $room = $row["r_no"]; if(!mysql_query ("INSERT INTO reservation VALUES ('0','$checkin', '$nyt', '$room', '$pac', '$id')")) { print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">'; print '<b>reservation failed</b>'; print '</div>'; } else { print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">'; print 'Your Information has been successfully added to the database.'; print '<br><br>'; $result=mysql_insert_id(); print "Your Reservation No. is <b>$result</b>"; print '</div>'; } } mysql_close(); ?> </body> </html> i did wat watever u told me Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/#findComment-361130 Share on other sites More sharing options...
MadTechie Posted October 3, 2007 Share Posted October 3, 2007 your missing the break; for one.. and as i said as a note i think your doing this the wrong way.. to start with whats the goal of this? Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/#findComment-361164 Share on other sites More sharing options...
aian04 Posted October 4, 2007 Author Share Posted October 4, 2007 ok 1st i have this reservation form for member... in reservation form i have checkin date, nyts per stay, room category id, packages id in my database reservation table i have checkin date nyts per stay room_no packacges id and Customer id.. in my database room table i have room category id floor level and room no.. now my goal is i want to retrieve the room no in room table using the post category id in the form... and the customer id will save as their login id... which i get from cookie id.. so when the query $room is executed... it will give me three different room no because the room category id is a foreign key from table room category... what i want is to execute the $room query wich will give me the 1st found room_no.. is it possible.. anyways i really appreciate ur reply.. tnx Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/#findComment-361461 Share on other sites More sharing options...
aian04 Posted October 4, 2007 Author Share Posted October 4, 2007 <html> <head> <link href="interface design/css.css" rel="stylesheet" type="text/css"> </head> <body class="bg"> <?php mysql_connect('localhost', 'root', 'tmc') or die(mysql_error()); mysql_select_db('tgp') or die(mysql_error()); $datein=$_POST['check-in-date']; $dayin=$_POST['check-in-day']; $r_type=$_POST['r_category']; $pac=$_POST['special']; $checkin = "$datein-$dayin" ; $nyt=$_POST['nyts']; $room= mysql_query("SELECT r_no FROM room WHERE r_no ='$r_type'order by rand() limit 1")or die(mysql_error()); $id=$_COOKIE['ID']; if(!mysql_query ("INSERT INTO reservation VALUES ('0','$checkin', '$nyt','$room','$pac','$id')")) { print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">'; print '<b>reservation failed</b>'; print '</div>'; } else { print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">'; print 'Your Information has been successfully added to the database.'; print '<br><br>'; $result=mysql_insert_id(); print "Your Reservation No. is <b>$result</b>"; print '</div>'; } mysql_close(); ?> </body> </html> bro now i can do select 1st found but the problem is its always failed... even i change the $room into number in insert into reservation stil not workin.. i feel bad.. the php dont want me... Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/#findComment-361844 Share on other sites More sharing options...
trq Posted October 4, 2007 Share Posted October 4, 2007 mysql_query() returns a result resource. You need to call mysql_fetch_assoc() to retrieve a row. Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/#findComment-361848 Share on other sites More sharing options...
aian04 Posted October 4, 2007 Author Share Posted October 4, 2007 ok it doesnt matter... my problem is the $room... it gives me "resource id#(the data in database) how to get the integer only.. i mean how to avoid that "resource id #" result.. Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/#findComment-361879 Share on other sites More sharing options...
trq Posted October 4, 2007 Share Posted October 4, 2007 See my last reply? See how you assign the return value from mysql_query() to $room? Now, read the link I provided there are examples there. Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/#findComment-361896 Share on other sites More sharing options...
aian04 Posted October 5, 2007 Author Share Posted October 5, 2007 ok i dont actually understand the mysql_fetch_assoc... how can i apply that argument? is it like this $row =mysql_fetch_assoc($room); Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/#findComment-362356 Share on other sites More sharing options...
MadTechie Posted October 5, 2007 Share Posted October 5, 2007 have you tried it ? example in this code.. Ah yeah will do that is none are found try this <?php mysql_select_db('tgp') or die(mysql_error()); $room= mysql_query("SELECT r_no FROM room WHERE r_no ='$r_type'")or die(mysql_error()); while ($row = mysql_fetch_assoc($room) ) {?> <html> <head> <link href="interface design/css.css" rel="stylesheet" type="text/css"> </head> <body class="bg"> <?php $datein=$_POST['check-in-date']; $dayin=$_POST['check-in-day']; $r_type=$_POST['r_category']; $pac=$_POST['special']; $checkin = "$datein-$dayin" ; $nyt=$_POST['nyts']; $id=$_COOKIE['ID']; mysql_connect('localhost', 'root', 'tmc') or die(mysql_error()); mysql_select_db('tgp') or die(mysql_error()); $room= mysql_query("SELECT r_no FROM room WHERE r_no ='$r_type'")or die(mysql_error()); while ($row = mysql_fetch_assoc($room) ) { $room = $row["r_no"]; //ive got error here in this line if(!mysql_query ("INSERT INTO reservation VALUES ('0','$checkin', '$nyt', '$room', '$pac', '$id')")) { print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">'; print '<b>reservation failed</b>'; print '</div>'; } else { print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">'; print 'Your Information has been successfully added to the database.'; print '<br><br>'; $result=mysql_insert_id(); print "Your Reservation No. is <b>$result</b>"; print '</div>'; break; } } mysql_close(); ?> </body> </html> Techie out, head killing now! Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/#findComment-362388 Share on other sites More sharing options...
aian04 Posted October 5, 2007 Author Share Posted October 5, 2007 <html> <head> <link href="interface design/css.css" rel="stylesheet" type="text/css"> </head> <body class="bg"> <?php mysql_connect('localhost', 'root', 'tmc') or die(mysql_error()); mysql_select_db('tgp') or die(mysql_error()); $datein=$_POST['check-in-date']; $dayin=$_POST['check-in-day']; $r_type=$_POST['r_category']; $pac=$_POST['special']; $checkin = "$datein-$dayin" ; $nyt=$_POST['nyts']; $room= mysql_query("SELECT r_no FROM room WHERE r_no ='$r_type'order by rand() limit 1"); $id=$_COOKIE['ID']; while ($row = mysql_fetch_row($room)){ echo $row="['r_no']"; break; } $r=mysql_free_result($room); if(!mysql_query ("INSERT INTO reservation VALUES ('0','$checkin', '$nyt','$r','$pac','$id')")or die(mysql_error())) { print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">'; print '<b>reservation failed</b>'; print '</div>'; } else { print '<div style=" width: 450px; background:black;filter:alpha(opacity=75); -moz-opacity:.75;opacity:.75; margin-left: 0; margin-right:0;">'; print 'Your Information has been successfully added to the database.'; print '<br><br>'; $result=mysql_insert_id(); print "Your Reservation No. is <b>$result</b>"; print '</div>'; } mysql_close(); ?> </body> </html> ok now i try dis code... i try to echo d $r then it remove the resource id thin... it give me pure integer... but its still give me failed reservation... wat do u think d problem... Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/#findComment-362394 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.