Jump to content

Archived

This topic is now archived and is closed to further replies.

somo

mysql help...

Recommended Posts

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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Another error lol

Undefined 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]

Share this post


Link to post
Share on other sites
You only need to specify the field name as the index:
[code]<?php $R_RoomAvailability = $row['R_RoomAvailiability']; ?>[/code]

Ken

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

×

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.