0

I am trying to run a mysql query in my php page.This query is not working.I suspect that i have misunderstood the concept of PDO and bind parametr.Kind help me to understand the concept using my query an example

$UIN = $_SESSION['login1'];
$sql ="SELECT tbluser.Dep,tbldep.Dep1 FROM tbluser JOIN tbldep on tbldep.id=tbluser.Dep WHERE tbluser.UIN=:UIN";
$query= $dbh -> prepare($sql);
$query-> bindParam(':UIN', $UIN, PDO::PARAM_INT);
$query-> execute();
$results=$query->fetchAll(PDO::FETCH_OBJ);
$Depart_Name=$results->Dep1;
$Depart_id=$results->Dep;
echo $Depart_Name;
echo $Depart_ID;
Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
leraner
  • 71
  • 6
  • What do you mean by "not working?" Does it throw an error or exception? If so, what was the error message? Does it return an unexpected result? What did you expect, and what does it return? – Bill Karwin Apr 14 '23 at 18:26
  • @BillKarwin It does not gives nay result – leraner Apr 14 '23 at 18:50
  • I reckon there are no rows in the table that match the value of `$UIN` value you are passing. What is the value? Have you tested the query in a MySQL query tool with that specific value written as a literal integer? – Bill Karwin Apr 14 '23 at 19:42

0 Answers0