somo Posted July 9, 2006 Share Posted July 9, 2006 I know this is simple but i just cant get it working.. how would you about return one value in a datbase?$result = mysql_query( "SELECT R_RoomAvailiability FROM Room WHERE R_ID='$R_ID' " )i need the value from this query can any one help?cheers Quote Link to comment https://forums.phpfreaks.com/topic/14103-mysql-help/ Share on other sites More sharing options...
ShogunWarrior Posted July 9, 2006 Share Posted July 9, 2006 Ok, first I think R_ID is probably a number so you don't need quotes, e.g: [b]$R_ID[/b] instead of [b]'$R_ID'[/b]To get the values do this:[code]$row = mysql_fetch_assoc($result);$R_Room_Availability = $row['SELECT R_RoomAvailiability'];[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14103-mysql-help/#findComment-55204 Share on other sites More sharing options...
somo Posted July 9, 2006 Author Share Posted July 9, 2006 im gettin a parse errror $result = mysql_query( "SELECT R_RoomAvailiability FROM Room WHERE R_ID=$R_ID " ) <b>$row = mysql_fetch_assoc($result); <---error is here for some reason</b> $R_RoomAvailability = $row['SELECT R_RoomAvailiability'];[quote author=ShogunWarrior link=topic=99971.msg394044#msg394044 date=1152461113]Ok, first I think R_ID is probably a number so you don't need quotes, e.g: [b]$R_ID[/b] instead of [b]'$R_ID'[/b]To get the values do this:[code]$row = mysql_fetch_assoc($result);$R_Room_Availability = $row['SELECT R_RoomAvailiability'];[/code][/quote] Quote Link to comment https://forums.phpfreaks.com/topic/14103-mysql-help/#findComment-55206 Share on other sites More sharing options...
Gast Posted July 9, 2006 Share Posted July 9, 2006 Try this:[code]<?php$result = mysql_query("SELECT R_RoomAvailiability FROM Room WHERE R_ID = ".$R_ID." LIMIT 1") or die(mysql_error());$row = mysql_fetch_assoc($result); //<---error is here for some reason$R_RoomAvailability = $row['SELECT R_RoomAvailiability'];echo $R_RoomAvailability;?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14103-mysql-help/#findComment-55208 Share on other sites More sharing options...
kenrbnsn Posted July 9, 2006 Share Posted July 9, 2006 You forgot the terminating semi-colon on this line:[code]<?php $result = mysql_query( "SELECT R_RoomAvailiability FROM Room WHERE R_ID=$R_ID " ) ?>[/code]Ken Quote Link to comment https://forums.phpfreaks.com/topic/14103-mysql-help/#findComment-55210 Share on other sites More sharing options...
somo Posted July 9, 2006 Author Share Posted July 9, 2006 Another error lolUndefined index: SELECT R_RoomAvailiability$result = mysql_query("SELECT R_RoomAvailiability FROM Room WHERE R_ID = ".$R_ID." LIMIT 1") or die(mysql_error());$row = mysql_fetch_assoc($result); <b>$R_Room_Availability = $row['SELECT R_RoomAvailiability']; //<-- error here now :( </b>[quote author=Gast link=topic=99971.msg394049#msg394049 date=1152462035]Try this:[code]<?php$result = mysql_query("SELECT R_RoomAvailiability FROM Room WHERE R_ID = ".$R_ID." LIMIT 1") or die(mysql_error());$row = mysql_fetch_assoc($result); //<---error is here for some reason</b>$R_RoomAvailability = $row['SELECT R_RoomAvailiability'];echo $R_RoomAvailability;?>[/code][/quote] Quote Link to comment https://forums.phpfreaks.com/topic/14103-mysql-help/#findComment-55213 Share on other sites More sharing options...
kenrbnsn Posted July 9, 2006 Share Posted July 9, 2006 You only need to specify the field name as the index:[code]<?php $R_RoomAvailability = $row['R_RoomAvailiability']; ?>[/code]Ken Quote Link to comment https://forums.phpfreaks.com/topic/14103-mysql-help/#findComment-55215 Share on other sites More sharing options...
somo Posted July 9, 2006 Author Share Posted July 9, 2006 Thanks for that its working now cheers! :)[quote author=kenrbnsn link=topic=99971.msg394056#msg394056 date=1152462879]You only need to specify the field name as the index:[code]<?php $R_RoomAvailability = $row['R_RoomAvailiability']; ?>[/code]Ken[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/14103-mysql-help/#findComment-55217 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.