Avatar of Jerry Kroger
Jerry Kroger
Flag for United States of America asked on

PHP select query on MS SQL SERVER 12

My client has a MS SQL Server 12 database table with a column - binary(8000)
It is populated with HashBytes('SHA1', '[concatenation of nvarchar entries of several other columns]').
Sample value is: 0x6C44CFB1C32C6E4ECDEBAC863FD5EA345681AC18

Using PHP 5.6.6, I collect the needed info to duplicate the concatenation described above and use the info to try to convert to an encryption to match the MS SQL SERVER 12 entry.
Nothing has worked yet  - I've tried many variations of a select statement like this one:
     $result="SELECT WebSiteEncryptedKey FROM Web.data where WebSiteEncryptedKey=HashBytes('SHA1',N'$webencryptedkey')";
     echo $result;
     echo "<br />";
     $rows = $db->query($result);
     if(!$rows)
     {
          die($db->errorInfo());
     } else {
          echo $rows; // line 102
     }
/*
RESULTS:
SELECT WebSiteEncryptedKey FROM Web.data where WebSiteEncryptedKey=HashBytes('SHA1',N'CURVATURESFP-10G-LR-CURV1154263')

Catchable fatal error: Object of class PDOStatement could not be converted to string in D:\inetpub\wwwroot\Registration.php on line 102
*/

Any help with doing this the correct way will be appreciated very much.
Thank you,
softexecware
Microsoft SQL ServerPHPSQL

Avatar of undefined
Last Comment
Jerry Kroger

8/22/2022 - Mon
SOLUTION
Brian Tao

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Vitor Montalvão

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Jerry Kroger

ASKER
Thank you Brian, and thank you Vitor.
Both comments were spot on.
Vitor, your detailed example was just what I needed to understand  the concept.

Again thanks to each of you.
softexecware
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy