In the below query,the "Account has been successfully approved" message dispayed. But in the database still approved_status remains '0'.

<?php
   
$connect=mysql_connect('localhost','root','');
mysql_select_db('bank',$connect);


if(isset($_POST['account_number']))
    $account_number=$_POST['account_number'];
else
    $account_number='';
	
$query = "UPDATE account_details SET approved_status='1' WHERE account_number='$account_number'";
$result= mysql_query($query) or die(mysql_error());

   if ($result)
   {
      echo "Account has been successfully approved";
   }
   
  
   
?>

Recommended Answers

All 3 Replies

There is no ; at the end of the sql query to tell MySQL to execute the code. Try this:

$query = "UPDATE account_details SET approved_status='1' WHERE account_number='$account_number';";
$result= mysql_query($query) or die(mysql_error());

I have already included it. But it still not working...

echo query before executing (as i did it below), then run page in browser, copy query and run in phpmyadmin, see where query updates account.
I think your account number is not matching.

<?php
   
$connect=mysql_connect('localhost','root','');
mysql_select_db('bank',$connect);


if(isset($_POST['account_number']))
    $account_number=$_POST['account_number'];
else
    $account_number='';
	
$query = "UPDATE account_details SET approved_status='1' WHERE account_number='$account_number'";
echo $query."<br>";
$result= mysql_query($query) or die(mysql_error());

   if ($result)
   {
      echo "Account has been successfully approved";
   }
   
  
   
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.