Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to insert binary data into MSSQL using PDO
    primarykey
    data
    text
    <p>I am currently experiencing a weird error. </p> <p>The setup: MSSQL Server 2012 Express with a localdb The target table collation is: SQL_Latin1_General_CP1_CI_AS</p> <p>PHP 5.3.9 on a Zend Server 5.6 MCrypt with MCRYPT_RIJNDAEL_256 and MCRYPT_MODE_ECB</p> <p>Sublime Text 2 default encoding (I read it is UTF8 BOM)</p> <p>I am using PDO with the official MS adapter for the MSSQL server. Everything works fine apart from one thing: I cannot write a row into my administrator table because of the password.</p> <p>Lets have a look at my ENCRYPTED password:</p> <pre><code>y"ûƒ^äjw¾bðúl5êù-Ö=W¿Š±¬GP¥Œy÷&amp;ø </code></pre> <p>This is the PDO Trace:</p> <pre><code>Array ( [0] =&gt; IMSSP [1] =&gt; -7 [2] =&gt; An error occurred translating string for input param 3 to UCS-2: No mapping for the Unicode character exists in the target multi-byte code page. ) SQL: [120] INSERT INTO administrator ( [username], [email], [password], [section] ) VALUES(:username, :email, :password, :section) Params: 4 Key: Name: [9] :username paramno=0 name=[9] ":username" is_param=1 param_type=2 Key: Name: [6] :email paramno=1 name=[6] ":email" is_param=1 param_type=2 Key: Name: [9] :password paramno=2 name=[9] ":password" is_param=1 param_type=2 Key: Name: [8] :section paramno=3 name=[8] ":section" is_param=1 param_type=2 </code></pre> <p>When I use my MSSQL Management Center I can insert my row with the exact same SQL query. The column setup is fine I suppose:</p> <pre><code> ["id"]=&gt; string(3) "int" ["username"]=&gt; string(12) "nvarchar(45)" ["email"]=&gt; string(12) "nvarchar(45)" ["password"]=&gt; string(12) "varbinary(45)" ["section"]=&gt; string(11) "nvarchar(7)" ["country_code"]=&gt; string(11) "nvarchar(2)" </code></pre> <p>I use prepared statements and the <code>bindParam</code> function with not extra options to execute my SQL statements.</p> <p>If anybody has an idea, how to solve that please let me know. Anykind of help is appreciated!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload