Search the Community
Showing results for tags 'php problem boolean value'.
-
Hi i am new to this forum and to the whole php ,wanted a hand at this code error : PHP Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\Inetpub\hello\tugapay.com\httpdocs\account\methods.php on line 37 I have been looking everywhere but nothing has pointed me to the right direction Please if someone could help me would be appreciated thanks My code is below <?php // If user submits login form if(isset($_POST['login_submit'])){ $results = mysql_query("SELECT `login_email` FROM `users` A WHERE `email` = 'login_email' AND `pass` = 'login_password'"); if(empty($_POST['login_email']) || empty($_POST['login_password'])){ $loginMessage = "<div style=\"padding-bottom: 15px;\"> <a href=\"#\" class=\"notification error\">Please fill in all the fields below.</a> </div>"; } elseif(mysql_num_rows($results) > 0){ $row = mysql_fetch_array($results); $_SESSION[‘users’] = $row['id']; header("Location: /account/dashboard.php"); } else { $loginMessage = "<div style=\"padding-bottom: 15px;\"> <a href=\"#\" class=\"notification error\">The information you entered was incorrect.</a> </div>"; } } // If user submits login form if(isset($_POST['transfer_submit'])){ $results = mysql_query("SELECT `id`, CONCAT(`first_name`, ' ',`lastname`) AS `name`, `balance` FROM `accounts` A WHERE `login_email` = '". $_POST['transfer_email'] ."'"); $row = mysql_fetch_array($results); if(empty($_POST['transfer_email']) || empty($_POST['transfer_amount']) || empty($_POST['transfer_description'])){ $transferMessage = "<div style=\"padding-bottom: 15px;\"> <a href=\"#\" class=\"notification error\">Please fill in all the fields below.</a> </div>"; } elseif(empty($row)) { $transferMessage = "<div style=\"padding-bottom: 15px;\"> <a href=\"#\" class=\"notification error\">Email address not found.</a> </div>"; } elseif($row['id'] == $_SESSION['account_id']){ $transferMessage = "<div style=\"padding-bottom: 15px;\"> <a href=\"#\" class=\"notification error\">You cannot send money to yourself.</a> </div>"; } elseif($_POST['transfer_amount'] > $account['balance']){ $transferMessage = "<div style=\"padding-bottom: 15px;\"> <a href=\"#\" class=\"notification error\">You have insufficient funds.</a> </div>"; } else { mysql_query("INSERT INTO transactions (account_id, from_id, amount, description, date, status) VALUES ('". $row['id'] ."', '". $_SESSION['account_id'] ."', '". $_POST['transfer_amount'] ."', '". $_POST['transfer_description'] ."', CURRENT_TIMESTAMP, '1')") OR die(mysql_error()); $balance = $account['balance'] - $_POST['transfer_amount']; mysql_query("UPDATE accounts SET balance = '". $balance ."' WHERE id = '". $_SESSION['account_id'] ."'"); $balance = $row['balance'] + $_POST['transfer_amount']; mysql_query("UPDATE accounts SET balance = '". $balance ."' WHERE id = '". $row['id'] ."'"); $transferMessage = "<div style=\"padding-bottom: 15px;\"> <a href=\"#\" class=\"notification success\">You have successfully sent <strong>£". number_format($_POST['transfer_amount'], 2) ."</strong> to <strong>". $row['name'] ."</strong></a> </div>"; unset($_POST); } } ?>