note 99746 deleted from function.mssql-query by cmb

From: Date: Sun, 23 Jun 2019 14:22:28 +0000
Subject: note 99746 deleted from function.mssql-query by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-211370@lists.php.net to get a copy of this message
Note Submitter: alpa at 33oxclove dot com ---- Hi All, I was trying to insert PDF in MSSQL image datatype and had a worst time figuring out how to add PDF without encoding it with base64_encode. Encoding/decoding works best but it was conflicting with other existing PDFs in database as they weren't encoded. The solution is to create hex string and the Trick is *NOT* to use quotes in query. <?php $FileName = $_FILES['pdffile']['tmp_name']; $dataString = file_get_contents($FileName ); $arrData = unpack("H*hex", $dataString); $hexdata = "0x".$arrData['hex']; ?> Query: $sql = "insert into docs(pdfname, pdfdoc) values('$pdfname', $hexdata) Hope this helps to someone.... Cheerzz

« previous php.notes (#211370) next »