PHP, home room

Status
Not open for further replies.

LoneZZ

Member
Oct 8, 2011
56
1
Hey guys, sorry for always posting help with my PHP codes, but I only started trying to add things the day before yesterday, so I still have some difficulty writting and comparing the codes to one already done.
I don't know what's wrong with this code, I really don't know why it doesn't work..

<?php
$homeroom = mysql_query("SELECT home_room FROM users WHERE id = '".$_SESSION['user']['id']."' LIMIT 1");
$gethomeroom = mysql_fetch_array($homeroom);
$homename = mysql_query("SELECT caption FROM rooms WHERE id = '".$gethomeroom."' LIMIT 1");
$getname = mysql_result($homename, 1);
echo $getname;
?>


I'd really appreciate if someone could find the problem in this, and get a fix, thanks in advance.
 

Xenous

o shi
Nov 15, 2011
383
101
Hey guys, sorry for always posting help with my PHP codes, but I only started trying to add things the day before yesterday, so I still have some difficulty writting and comparing the codes to one already done.
I don't know what's wrong with this code, I really don't know why it doesn't work..

<?php
$homeroom = mysql_query("SELECT home_room FROM users WHERE id = '".$_SESSION['user']['id']."' LIMIT 1");
$gethomeroom = mysql_fetch_array($homeroom);
$homename = mysql_query("SELECT caption FROM rooms WHERE id = '".$gethomeroom."' LIMIT 1");
$getname = mysql_result($homename, 1);
echo $getname;
?>


I'd really appreciate if someone could find the problem in this, and get a fix, thanks in advance.

This should work >.> as you are returning an array and trying to query it which won't work.
PHP:
<?php
$homeroom = mysql_query("SELECT home_room FROM users WHERE id = '".$_SESSION['user']['id']."' LIMIT 1");
$gethomeroom = mysql_result($homeroom, 1);
$homename = mysql_query("SELECT caption FROM rooms WHERE id = '".$gethomeroom."' LIMIT 1");
$getname = mysql_result($homename, 1);
echo $getname;
?>
 

LoneZZ

Member
Oct 8, 2011
56
1
This should work >.> as you are returning an array and trying to query it which won't work.
PHP:
<?php
$homeroom = mysql_query("SELECT home_room FROM users WHERE id = '".$_SESSION['user']['id']."' LIMIT 1");
$gethomeroom = mysql_result($homeroom, 1);
$homename = mysql_query("SELECT caption FROM rooms WHERE id = '".$gethomeroom."' LIMIT 1");
$getname = mysql_result($homename, 1);
echo $getname;
?>

That was how I had it first, I tried the code you posted anyway, and I get:

Warning: mysql_result() [ ]: Unable to jump to row 1 on MySQL result index 29 inC:\xampp\htdocs\app\tpl\skins\Habbo\home.php on line 216

Warning: mysql_result() [ ]: Unable to jump to row 1 on MySQL result index 30 inC:\xampp\htdocs\app\tpl\skins\Habbo\home.php on line 218


Does this mean I don't have a homeroom? because I do on the client, and in the database it gives me the roomid, wich is 11 :/
 
Status
Not open for further replies.

Users who are viewing this thread

Top