0
I’m making a site to generate promotional coupons, but at the time of saving in the database is giving this error. Notice: Array to string Conversion in. would like to know if anyone can help me. follow the code below:
// comes from the form
$preco = $_POST['preco'];
$promo = $_POST['promo'];
// conta
$resultado = $preco / $promo;
// generates the random number ]
for ($i = 1; $i <= $resultado; $i++) { $n[] = str_pad(rand(10000000, 99999999), 2, '0', STR_PAD_LEFT); }
sort($n);
echo implode('<br/>', $n);
Registration fee($connection, $price, $promo, $n){
$inserir = "insert into cupons (preco, promo, cupons) values ({$preco}, {$promo}, '{$n}')";
$resultadoDaInsercao = mysqli_query($conexao, $inserir);
return $resultadoDaInsercao;
}
if(cadastracaixa($connexion, $preco, $promo, $n)){ echo "Alert('successfully entered data');"; }Else{ $msg = mysqli_error($connected); echo "Alert('data not entered. Try again');"; }
$n[] is an array, you need to convert it to string.
– user178974