oci_bind_by_name not working in PHP
Can anyone guide me on using oci_bind_by_name. I have written this piece of code:
$connection = initDB();
$validation_query = "SELECT * from admin where admin_id= :uid and password= :pwd";
$s = oci_parse($connection, $validation_query);
oci_bind_by_name($s, ':uid', $id);
oci_bind_by_name($s, ':pwd', $pass);
$res=oci_execute($s, OCI_DEFAULT);
$result_row = oci_fetch_array($s, OCI_ASSOC);
But with slight modification to Code and generating the query on the fly, it starts working.
$connection = initDB();
$validation_qu开发者_如何学编程ery = "SELECT * from admin where admin_id= '".$id."' and password= '".$pass."'";
$s = oci_parse($connection, $validation_query);
//oci_bind_by_name($s, ':uid', $id);
//oci_bind_by_name($s, ':pwd', $pass);
$res=oci_execute($s, OCI_DEFAULT);
$result_row = oci_fetch_array($s, OCI_BOTH);
I have no idea on this and have already searched forums and internet. Kindly help me out.
GOT IT ! Sorry to bother you guys... I made a silly mistake.
The line of code: $result_row = oci_fetch_array($s, OCI_BOTH)
was being executed in both the codes. But in Second scenario $result_row[0]
returned values where as $result_row[0]
fails in 1st scenario.
This is again because I was using different MODES of fetching data. OCI_ASSOC in first case and OCI_BOTH in second case.
So finally when I wrote $result_row['ID']
, I got the desired results.
Cheers !
精彩评论