SQL SELECT statement in PHP -
which 1 correct?
having trouble single quotes vs double quotes in php , using oracle 11g db...
<?php $query1 = oci_parse($conn, 'select * schema.table_a b_id=' . $id); $query1 = oci_parse($conn, "select * schema.table_a b_id='" . $id . "'"); ?>
if id numeric, should not quote value. if it's character string, should.
regardless, using string manipulation create sql statement bad practice leaves application vulnerable sql injection attacks. instead, should use prepared statement:
$query1 = oci_parse($conn, 'select * schema.table_a b_id=:id'); oci_bind_by_name($query1, ":id", $id); oci_execute($query1);
Comments
Post a Comment