0

On submission, this is my code:

if(isset($_POST['send_money'])) {
     $date = explode("/",date('d/m/Y/h/i/s'));
     list($day,$month,$year,$hour,$min,$sec) = $date;
     $transaction_id = 'GMT'. $year .'.'.$day.$month.'.'.$hour . $min.$sec;
     $amount = mysqli_real_escape_string($conn, $_POST['amount']);
     $sender = mysqli_real_escape_string($conn, $_POST['sender']);
     $receiver = mysqli_real_escape_string($conn, $_POST['receiver']);
     $collected = FALSE; // Boolean data type in database
     $approved = FALSE; // Boolean data type in database
$stmt = $conn->prepare("INSERT INTO transactions (transaction_id, date_of_transaction, amount,sender, receiver, collected, approved) 
  VALUES(?,now(), ?, ?, ?, ?, ?, ?)");
$stmt->bind_param("sdssss", $transaction_id, $amount, $sender, $receiver $collected, $approved);  
$query = $stmt->execute();
if($query){
    array_push($errors, "<h4 class='text-success text-center'>Transaction completed successfully</h4><hr/>");
  }else{
    array_push($errors, "<h4 class='text-danger text-center'>Couldn't complete transaction</h4><hr/>");
  }
} 

The query cannot send the data to the database and can you assist in;

  • Inserting DATETIME using MySQLi parameter binding
  • Inserting BOOLEAN using MySQLi parameter binding
7
  • Just like any other string. What's the problem now? Commented Aug 10, 2021 at 16:51
  • Warning! $amount should not be a float/double. Money should be stored using DECIMAL type and used as a string in PHP/mysqli Commented Aug 10, 2021 at 16:51
  • So l should parse them as a string s ?? Commented Aug 10, 2021 at 16:54
  • 1
    mysqli_real_escape_string should not be used with prepared statement. This will damage your data. Commented Aug 10, 2021 at 16:55
  • 1
    Send everything as string in mysqli. Commented Aug 10, 2021 at 16:55

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.