par
chegmarco » 26 janv. 2022, 16:54
Je reçois à présent l'erreur:
Erreur SQL : Field 'acc_amount' doesn't have a default value
,
quand j'ajoute le
mysqli->error comme vous venez de me le conseiller:
Code : Tout sélectionner
if ($stmt->execute()) {
if ($notification_stmt->execute()) {
$success = "Money Deposited";
} else {
$err = "Please Try Again Or Try Later";
die('Erreur SQL : ' . $notification_stmt->error);
}
} else {
$err = "Please Try Again Or Try Later";
die('Erreur SQL : ' . $stmt->error);
}
Mais le souci c'est que le champs
acc_amount du même Utilisateur dont on fait le
Deposit, dans mon code est dans la Table
iB_bankAccounts de la même BDD contrairement aux autres champs et informations qui sont dans la Table
iB_Transactions de la Base de données, et donc, j'ai fait ceci:
Code : Tout sélectionner
if (isset($_POST['deposit'])) {
$tr_code = $_POST['tr_code'];
$account_id = $_GET['account_id'];
$acc_name = $_POST['acc_name'];
$account_number = $_GET['account_number'];
$acc_type = $_POST['acc_type'];
//$acc_amount = $_POST['acc_amount'];
$tr_type = $_POST['tr_type'];
$tr_status = $_POST['tr_status'];
$client_id = $_GET['client_id'];
$client_name = $_POST['client_name'];
$client_national_id = $_POST['client_national_id'];
$transaction_amt = $_POST['transaction_amt'];
$client_phone = $_POST['client_phone'];
//$acc_new_amt = $_POST['acc_new_amt'];
//Notication
$notification_details = "$client_name Has Deposited Ksh $transaction_amt To Bank Account $account_number";
//Insert Captured information to a database table
$query = "INSERT INTO iB_Transactions (tr_code, account_id, acc_name, account_number, acc_type, tr_type, tr_status, client_id, client_name, client_national_id, transaction_amt, client_phone) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)";
$notification = "INSERT INTO iB_notifications (notification_details) VALUES (?)";
$stmt = $mysqli->prepare($query);
$notification_stmt = $mysqli->prepare($notification);
//bind paramaters
$rc = $notification_stmt->bind_param('s', $notification_details);
$rc = $stmt->bind_param('ssssssssssss', $tr_code, $account_id, $acc_name, $account_number, $acc_type, $tr_type, $tr_status, $client_id, $client_name, $client_national_id, $transaction_amt, $client_phone);
$stmt->execute();
$notification_stmt->execute();
//declare a varible which will be passed to alert function
if ($stmt->execute()) {
if ($notification_stmt->execute()) {
$success = "Money Deposited";
} else {
$err = "Please Try Again Or Try Later";
die('Erreur SQL : ' . $notification_stmt->error);
}
} else {
$err = "Please Try Again Or Try Later";
die('Erreur SQL : ' . $stmt->error);
}
}
if(isset($_POST['deposit']))
{
$account_id = $_GET['account_id'];
$acc_amount = $_POST['acc_amount'];
//Insert Captured information to a database table
$query="UPDATE iB_bankAccounts SET acc_amount=? WHERE account_id=?";
$stmt = $mysqli->prepare($query);
//bind paramaters
$rc=$stmt->bind_param('si', $acc_amount, $account_id);
$stmt->execute();
//declare a varible which will be passed to alert function
if($stmt )
{
$success = "Money Deposited";
}
else
{
$err = "Please Try Again Or Try Later";
}
}
Et pourtant la même erreur:
Erreur SQL : Field 'acc_amount' doesn't have a default value.
Comment donc mettre à jour le champs "
acc_amount" (
qui représente le solde de l'Utilisateur dont on cherche à créditer le compte) et situé dans la Table
iB_bankAccounts à chaque fois que je fais un Dépôt ?
Je reçois à présent l'erreur:
[quote]Erreur SQL : Field 'acc_amount' doesn't have a default value[/quote],
quand j'ajoute le [b]mysqli->error[/b] comme vous venez de me le conseiller:
[code]if ($stmt->execute()) {
if ($notification_stmt->execute()) {
$success = "Money Deposited";
} else {
$err = "Please Try Again Or Try Later";
die('Erreur SQL : ' . $notification_stmt->error);
}
} else {
$err = "Please Try Again Or Try Later";
die('Erreur SQL : ' . $stmt->error);
}[/code]
Mais le souci c'est que le champs [b]acc_amount[/b] du même Utilisateur dont on fait le [b]Deposit[/b], dans mon code est dans la Table [b]iB_bankAccounts[/b] de la même BDD contrairement aux autres champs et informations qui sont dans la Table [b]iB_Transactions[/b] de la Base de données, et donc, j'ai fait ceci:
[code]if (isset($_POST['deposit'])) {
$tr_code = $_POST['tr_code'];
$account_id = $_GET['account_id'];
$acc_name = $_POST['acc_name'];
$account_number = $_GET['account_number'];
$acc_type = $_POST['acc_type'];
//$acc_amount = $_POST['acc_amount'];
$tr_type = $_POST['tr_type'];
$tr_status = $_POST['tr_status'];
$client_id = $_GET['client_id'];
$client_name = $_POST['client_name'];
$client_national_id = $_POST['client_national_id'];
$transaction_amt = $_POST['transaction_amt'];
$client_phone = $_POST['client_phone'];
//$acc_new_amt = $_POST['acc_new_amt'];
//Notication
$notification_details = "$client_name Has Deposited Ksh $transaction_amt To Bank Account $account_number";
//Insert Captured information to a database table
$query = "INSERT INTO iB_Transactions (tr_code, account_id, acc_name, account_number, acc_type, tr_type, tr_status, client_id, client_name, client_national_id, transaction_amt, client_phone) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)";
$notification = "INSERT INTO iB_notifications (notification_details) VALUES (?)";
$stmt = $mysqli->prepare($query);
$notification_stmt = $mysqli->prepare($notification);
//bind paramaters
$rc = $notification_stmt->bind_param('s', $notification_details);
$rc = $stmt->bind_param('ssssssssssss', $tr_code, $account_id, $acc_name, $account_number, $acc_type, $tr_type, $tr_status, $client_id, $client_name, $client_national_id, $transaction_amt, $client_phone);
$stmt->execute();
$notification_stmt->execute();
//declare a varible which will be passed to alert function
if ($stmt->execute()) {
if ($notification_stmt->execute()) {
$success = "Money Deposited";
} else {
$err = "Please Try Again Or Try Later";
die('Erreur SQL : ' . $notification_stmt->error);
}
} else {
$err = "Please Try Again Or Try Later";
die('Erreur SQL : ' . $stmt->error);
}
}
if(isset($_POST['deposit']))
{
$account_id = $_GET['account_id'];
$acc_amount = $_POST['acc_amount'];
//Insert Captured information to a database table
$query="UPDATE iB_bankAccounts SET acc_amount=? WHERE account_id=?";
$stmt = $mysqli->prepare($query);
//bind paramaters
$rc=$stmt->bind_param('si', $acc_amount, $account_id);
$stmt->execute();
//declare a varible which will be passed to alert function
if($stmt )
{
$success = "Money Deposited";
}
else
{
$err = "Please Try Again Or Try Later";
}
}[/code]
Et pourtant la même erreur: [b]Erreur SQL : Field 'acc_amount' doesn't have a default value[/b].
Comment donc mettre à jour le champs "[b]acc_amount[/b]" ([i]qui représente le solde de l'Utilisateur dont on cherche à créditer le compte[/i]) et situé dans la Table [b]iB_bankAccounts[/b] à chaque fois que je fais un Dépôt ?