Jump to content

mysql help...


somo

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
Link to comment
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]
Link to comment
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]
Link to comment
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]
Link to comment
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]
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.