Need a lil help with game money code.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
xwhitchx
Forum Commoner
Posts: 38
Joined: Mon Jun 21, 2010 4:30 pm

Need a lil help with game money code.

Post 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");
}


?>
Phoenixheart
Forum Contributor
Posts: 123
Joined: Tue Nov 16, 2004 7:46 am
Contact:

Re: Need a lil help with game money code.

Post 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.
xwhitchx
Forum Commoner
Posts: 38
Joined: Mon Jun 21, 2010 4:30 pm

Re: Need a lil help with game money code.

Post 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
Post Reply