I am creating a simple query in mySql to insert some values from a form into my db.
My question is simple, but in reference to the difference between binding variables vs specifying them into the sql statement.
Binding:
$query = "INSERT INTO test (name, lastName, price) VALUES (:name, :lastName, :price)";
$apply = $con -> prepare($query);
$apply -> execute (array(':name'=>$name,':lastName'=>$lastName,':price=>$price'));
Typical:
$query = "INSERT INTO test (name, lastName, price) VALUES ($name, $lastName, $price)";
Execute the query....
Is the Binding option really recommended even for simple cases as the one above? Why is that?
Thanks!