$stmt=$con->query("insert into tbl(data) values(0x".$data1['hex'].")");
This is the sql statement and its works just fine. The value
0xFFD8FFE000104A46494600010101006000600000FFDB00430...
gets stored on the database and i have checked, the image gets stored. But i am trying to do this using PDO and the stored value is different and does not show the image. Here is my code
$datastring = file_get_contents("image.JPG");
$data1 = unpack("H*hex", $datastring);
$data = '0x'.$data1['hex'];
$stmt=$conp->prepare("insert into tbl(data) values(:data)");
$stmt->bindparam(':data', $data);
$stmt->execute();
The value in database
0x30786666643866666530303031303461343634393436303...
What is making the difference? Am I doing something wrong with it? I am using SQL Server 2008R2 with Microsoft pdo_odbc driver on php 5.6.