joe91
11-08-2006, 09:59 PM
Hiya, I was wondering if anybody can help.
I have a website which i have a login script for however I want to users to be able to have an account balance. I have set up a field for balance in the users table of my database however I am having problems fetching the correct row for each user.
This is my code:
<?php
$mysqlLink = mysql_connect( 'mysql2.freehostia.com' , 'My Username', 'My Password' );
mysql_select_db( 'joesha1_members' , $mysqlLink );
$result = mysql_query("SELECT * FROM `users` WHERE `username`= ".$_SESSION['username']." AND `password`=".$_SESSION['password']." ");
while( $row = mysql_fetch_array($result) )
{
echo $row[ 'username' ] . $row[ 'balance' ];
}
mysql_close( $mysqlLink );
?>
It keeps on displaying this error
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/www/joesha1.freehostia.com/account.php on line 19
Thanks and hope i made any sence, Joe
I have a website which i have a login script for however I want to users to be able to have an account balance. I have set up a field for balance in the users table of my database however I am having problems fetching the correct row for each user.
This is my code:
<?php
$mysqlLink = mysql_connect( 'mysql2.freehostia.com' , 'My Username', 'My Password' );
mysql_select_db( 'joesha1_members' , $mysqlLink );
$result = mysql_query("SELECT * FROM `users` WHERE `username`= ".$_SESSION['username']." AND `password`=".$_SESSION['password']." ");
while( $row = mysql_fetch_array($result) )
{
echo $row[ 'username' ] . $row[ 'balance' ];
}
mysql_close( $mysqlLink );
?>
It keeps on displaying this error
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/www/joesha1.freehostia.com/account.php on line 19
Thanks and hope i made any sence, Joe