0

I am getting below values in Browser & I saved AWBNoSeries values in Database....

ReturnMessage": "AWBNoSeries":["1234","5678",

enter image description here

Now i need to save other 2 column values in mysql table ecomexpress_awb & in columns [ awb_type & status ].... When i tried below code, i dont get any error, but other 2 column values will not save in DB....

<?php

$mysqli = mysqli_connect("localhost","root","","do_management4");
$parsedData = json_decode($curl_response, true);
$stmt = $mysqli->prepare("INSERT INTO ecomexpress_awb(awb,awb_type,status) VALUES (?,?,?)"); 

$cod="COD";
$status="unused";

//loop through values and insert each one into the db
foreach ($parsedData['AWBNoSeries'] as $awb){
    $stmt->bind_param("iii", $awb , $cod, $status);
    $stmt->execute();
}

$stmt->close(); 
mysqli_close($mysqli); 

?>

1 Answers1

0

In your bind you are saying that all the values are integers ("iii")...

$stmt->bind_param("iii", $awb , $cod, $status);

I'm assuming you want strings....

$stmt->bind_param("iss", $awb , $cod, $status);
Nigel Ren
  • 56,122
  • 11
  • 43
  • 55
  • It's also worth checking for errors as this usually shows what is not working - https://stackoverflow.com/questions/22662488/how-to-get-mysqli-error-information-in-different-environments – Nigel Ren Nov 21 '18 at 07:39
  • what we need to give for `datetime - d` ? –  Nov 21 '18 at 07:52
  • Dates are passed as strings ( so `s`) Have a read through http://php.net/manual/en/mysqli-stmt.bind-param.php which has some examples. – Nigel Ren Nov 21 '18 at 07:53