SQL binary value to PHP variable leading zeros
- by Agony
Using sql query to pull data from a mssql database results in a value that still has leading zeros.
The data in database is stored as binary(13) - so it will pull all 13 digits.
However the value is a text, so any leading zeros will generally show up as '?' in a form on the site - and in return will update wrong data to the database later.
So what i need is to only select/display the text itself, not all 13 bytes.
using:
SELECT CONVERT(char,uilock_pw) AS uipwd FROM tbl_UserAccount
or
SELECT uilock_pw FROM tbl_UserAccount
still adds the leading zeros to the char array.
Example in database:
0x71776531323300000000000000
Would show up as:
qwe123???????
But should be:
qwe123
Im not even sure what character those ? represent. Using Echo results in a normal qwe123 - but not in a form.