I have x, y and z which are arrays. The data is displayed correctly, but I cannot force it to be inserted into my database. It inserts the correct number of rows as all 0, and not the int values ββentered by the user. Here is the php.
$x = $_POST['x'];
$y = $_POST['y'];
$z = $_POST['z'];
foreach($x as $result){
$query = 'INSERT INTO table
(x, y, z)
VALUES (:x, :y, :z)';
$statement = $db->prepare($query);
$statement->bindValue(':x', $x);
$statement->bindValue(':y', $y);
$statement->bindValue(':z', $z);
$statement->execute();
$statement->closeCursor();
}
I get this error: Note: an array to convert strings to
It is on all three lines of bindValue
I know that foreach is wrong, but this is the only cycle I have encountered. Gives me the correct number of rows, but only inserts 0 into the database.
source
share