I'm building an application that requires users to be able to see their account balances. The respective data (integers) are stored in a MySQL table.
The code I am using is as follows:
Code: Select all
session_start();
include ('inc/header.php');
include ('inc/left.php');
include ('inc/footer.php'); //Include the HTML footer.
$balance = "SELECT balance FROM at_client_profile WHERE email = ('$e') AND password = ('$p')";
$result = mysql_num_rows ($balance); //Assigns balance from SQL query to $result variable.
if ($result > 0) { //If it ran OK, display the records.
echo "<p><big> <b> The outstanding balance on your account is $result </b></big></p>";
mysql_free_result ($result); //Free up the resources.
} else {
echo '<p> You do not have a balance outstanding. If you wish to enquire further pleace call a member of staff.</p>'; //If it did not run ok.
}
mysql_close();
if(isset($_SESSION['client_id']) AND ($_SERVER['PHP_SELF'] -10) != 'client_profile.php') { //Had to edit the call to '(subs($_SERVER['PHP_SELF'], as was regarded as being an undefined function. Reverted to ($_SERVER[PHP_SELF'] amd logout notation was implemented on header
echo '<a href="client_profile.php">Return to my Client Area<br /></a>';
} else {
echo '<a href="client_login.php"></a>';
}
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\Atkinsons\account_balance.php on line 10
Do I need to include the 'require_once ()'? Am I missing an 'include ()' at the top of the script??...
Any help would again be appreciated