Why does the first insert method work, not another one?

22 hours ago 4
ARTICLE AD BOX

I need to use insert method that prevent again injection attacks.

Need to understand the why and to learn also.

When I use these code its works PERFECTLY:

<form action="my_insert_method" method="post"> <input type="text" name="description" value=""> <input type="submit" name="add"> </form> <?php include_once 'testdb.php'; if(isset($_POST['add'])) { //error_reporting(E_ALL); //ini_set('display_errors', '1'); $description = $_POST['description_1']; $sql = 'INSERT INTO restaurante(description_1) VALUES("'.$_POST['description1'] . '")'; if (mysqli_query($conn, $sql)) { echo "Save successfully!"; } else { echo "Error: " . $sql . " " . mysqli_error($conn); } mysqli_close($conn); } ?>

Curiosly, the other code doesnt works and not show any error meesage:

<?php include_once 'testdb.php'; if(isset($_POST['add'])){ $addQuery = "INSERT INTO restaurante(description_1) VALUES(?)"; $addStatement = $this->dbc->prepare($addQuery); $addStatement->bind_param('s', 'description1'); $addStatement->execute(); } ?>
Read Entire Article