Page 1 of 1

Need a lil help with game money code.

Posted: Mon Jun 21, 2010 4:44 pm
by xwhitchx
hello every one,
im maybe 4 days into learning php/mysql, im making a text bases sim game, and im having problems with making a money system that will work. all im wanting to do is display the players money on the screen for them to see, but when i tell it to find the money in the players account it will only display "Resource id #4", so i tryed to see if it could find a username and i get the same thing, so im stuck. so anyhelp would be very nice.
thx for your time

Code: Select all

<?php
session_start();
include('confff.php');

$loggedinuser = $_SESSION['username'];
$findusername = mysql_query("SELECT * FROM users WHERE username = '$loggedinuser'");
$nspoints = mysql_query("SELECT nspoints FROM users WHERE username ='$loggedinuser'");
if(isset($loggedinuser))
{

echo 'hello?<br/>';
echo $loggedinuser;
echo $findusername;
echo '<br>'.$nspoints;


}

else
{
header("Loction: loginpage.php");
}


?>

Re: Need a lil help with game money code.

Posted: Mon Jun 21, 2010 10:38 pm
by Phoenixheart
It's because your $nspoints is just a MySQL result set object. You need to fetch data from it.
Look for mysql_fetch_array, mysql_fetch_assoc, mysql_fetch_row, or mysql_fetch_object.

Re: Need a lil help with game money code.

Posted: Tue Jun 22, 2010 3:24 am
by xwhitchx
Phoenixheart wrote:It's because your $nspoints is just a MySQL result set object. You need to fetch data from it.
Look for mysql_fetch_array, mysql_fetch_assoc, mysql_fetch_row, or mysql_fetch_object.
alright ill look that up, and try to get it to work with that, thanks for the help. :D