MadTechie Posted October 5, 2007 Share Posted October 5, 2007 echo $row="['r_no']"; should be echo $row['r_no']; Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/page/2/#findComment-362401 Share on other sites More sharing options...
aian04 Posted October 6, 2007 Author Share Posted October 6, 2007 <?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']; $id=$_COOKIE['ID']; $room= mysql_query("SELECT r_no FROM room WHERE RC_id ='$r_type'order by rand() limit 1"); while ($row = mysql_fetch_row($room)){ break; } $r= mysql_free_result($room); echo "$r"; if(!mysql_query ("INSERT INTO reservation VALUES ('0','$checkin', '$nyt','$r','$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(); ?> if i use this code its always give me number 1.. which is wrong.. and its not following my $room query... Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/page/2/#findComment-363228 Share on other sites More sharing options...
MadTechie Posted October 6, 2007 Share Posted October 6, 2007 you probably don't have an auto number setup in the database Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/page/2/#findComment-363240 Share on other sites More sharing options...
aian04 Posted October 6, 2007 Author Share Posted October 6, 2007 what do u mean auto number?? i have info in my room table.. what i want to do is to get the r_no in the table... but this code is not getting the r_no.. its only give me number 1 result... tnx for ur reply anyway... Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/page/2/#findComment-363253 Share on other sites More sharing options...
~n[EO]n~ Posted October 6, 2007 Share Posted October 6, 2007 what do u mean auto number?? i have info in my room table.. i think he means auto_increment CREATE TABLE `contacts` ( `co_id` int(9) NOT NULL [b]auto_increment[/b] Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/page/2/#findComment-363263 Share on other sites More sharing options...
aian04 Posted October 6, 2007 Author Share Posted October 6, 2007 my r_no column is auto_incremented.. and it doesnt matter if it is or it isnt... coz i only want to get the data from r_no column... and put that obtained data to reservation table... this is my room table create table room ( RC_id varchar(15) not null, floorlvl int not null, R_no int not null auto_increment, primary key (R_no), Foreign Key (RC_id) references r_category(RC_id) ); and this is my reservation table create table reservation ( Res_id int not null auto_increment, check_in date not null, night_per_stay int not null, R_no int not null, pac_id varchar(15) not null, Cid varchar(15) not null, primary key (Res_id), Foreign Key (Cid) references member(Cid), Foreign Key (pac_id) references packages(pac_id), Foreign Key (R_no) references room(R_no) ); Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/page/2/#findComment-363274 Share on other sites More sharing options...
MadTechie Posted October 6, 2007 Share Posted October 6, 2007 what i want to do is to get the r_no in the table... i just noticed you ignored my last post.. go back and try that it seam your just trying anything to make it work without the understanding <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... echo $row="['r_no']"; should be echo $row['r_no']; Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/page/2/#findComment-363276 Share on other sites More sharing options...
aian04 Posted October 6, 2007 Author Share Posted October 6, 2007 ok now i change it... now i can get it... and its randomize.... $room= mysql_query("SELECT r_no FROM room WHERE rc_id ='$r_type'order by rand() limit 1"); while ($row = mysql_fetch_assoc($room)){ echo $row['r_no']; break; } $r= mysql_free_result($room); how to insert it in the reservation table if(!mysql_query ("INSERT INTO reservation VALUES ('0','$checkin', '$nyt','$r','$pac','$id')")) do i need to change the $r to $row... Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/page/2/#findComment-363287 Share on other sites More sharing options...
MadTechie Posted October 6, 2007 Share Posted October 6, 2007 $room= mysql_query("SELECT r_no FROM room WHERE rc_id ='$r_type'order by rand() limit 1"); $row = mysql_fetch_assoc($room); //don't need to loop echo $row['r_no']; $r = $row['r_no']; //added mysql_free_result($room); //removed the $r= Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/page/2/#findComment-363289 Share on other sites More sharing options...
aian04 Posted October 6, 2007 Author Share Posted October 6, 2007 ok now its smooth... but i didnt put the mysql_free_result... which i think it does not matter... tnx bro... now 1st problem is solve... Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/page/2/#findComment-363291 Share on other sites More sharing options...
~n[EO]n~ Posted October 6, 2007 Share Posted October 6, 2007 Huh... we can still reply to the Solved Topics... :o I didn't know that .... LOL Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/page/2/#findComment-363296 Share on other sites More sharing options...
MadTechie Posted October 6, 2007 Share Posted October 6, 2007 Topic solved is just a tag to you don't have to look in every post to try to help Quote Link to comment https://forums.phpfreaks.com/topic/71704-solved-php-processing/page/2/#findComment-363302 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.