good morning
Working with php, I'm making a shopping cart. everything was fine until I realized that it does not save me values with decimals, pure integers in tables such as prices or totals, etc.
my tables had them in decimal type, then I changed them to double and I did not affect anything. Only when the data has decimals sends me this error:
total Compra1 :16073
total desc 1607,3
total Compra:14465,7
error al insertar datos de compra Column count doesn't match value count at row 1
I printed the values that I have to see the accounts. in that example if I do not remove the discount, save it without errors
and this is the insert code
echo '<br>total Compra1 :'.$totalCompra.'<br>';
$totalDescuento=$totalCompra*($descuentoStatus/100);
echo 'total desc '.$totalDescuento;
$totalCompra= $totalCompra-$totalDescuento;
echo '<br>total Compra:'.$totalCompra.'<br>';
//$totalCompra=$totalCompra+$gastosEnvio;
mysqli_query( $conexion, "INSERT INTO compras (numeroCompra, idDistr, nomDistr, fechaCompra, formaPago, articulos, totalCompra, descuento, statusCompra) VALUES ('$numeroCompra','$IDUSUARIO','$nomUsuario', ' $fecha', '$formaPago', '$articulosTotal', $totalCompra, '$descuentoStatus', '$statusCompra')" )or die( "error al insertar datos de compra " . mysqli_error( $conexion ) );
To insert it well. I added this code to format with the . point, but how can I do it so that the format is applied to all the pages. Or I do variable by variable
number_format($número, 2, '.', '');
// 1234.56