I would like to know is it ok to use variables in mysql functions inside php? While ofcourse making sure that the variables values not being received directly from client inputs.
For example is it better to use one of those queries on the other?
$stat = $db->prepare("INSERT INTO table(`col1`, `col2`, `image`)
VALUES ('$val1', '$val2')");
$stmt = $dbh->prepare("INSERT INTO table(`col1`, `col2`)
VALUES (:val1, :val2)");
$stmt->bindParam('col1',$val1);
$stmt->bindParam('col2',$val2);