Can someone tell me why I'm not getting data in my $result?

<?php
$serverName = "SQL\SQL"; //serverName\instanceName


$connectionInfo = array( "Database"=>"GDB_01_001", "UID"=>"sa", "PWD"=>"xxx-1x");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
$command = "select CASE when (STOCKWH.MFG) is null then ' ' else STOCKWH.MFG,

STOCK.PARTNUMBER as 'Part Number', STOCK.DESCRIPTN as 'Description', STOCK.QTY_INSTOCKCOND

as 'Condition', STOCKWH.MFG as 'Mfg Code', STOCKWH.QTY as 'Qty' from [stock] inner join

STOCKWH on STOCK.PARTNUMBER = STOCKWH.PARTNUMBER where STOCKWH.QTY > 0 order by

STOCK.PARTNUMBER";
if( $conn ) {
     echo "Connection established.<br />";
$result = sqlsrv_query($conn,$command);
echo $result;
echo "<br />End of job";

}else{
     echo "Connection could not be established.<br />";
     die( print_r( sqlsrv_errors(), true));
}
?>


I can get connection successful and end of job but cannot get any data between the two =\ Must be something wrong with my sql query? or using a $ instead of an @? The SQL query works perfectly in management studio even though it fills one of the columns with "nulls." If someone can figure out a way to filter those out too that would be awesome.

I'm betting it needs to be an array some how.


MS SQL 2008 + Apache + PHP 5.2 + Windows 2008 SBS (OLD version of WAMP5)
E J PopeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

E J PopeAuthor Commented:
I modified the code to get more error logs and got this:

Error in statement execution. Array ( [0] => Array ( [0] => 42000 [SQLSTATE] => 42000 [1] => 102 [code] => 102 [2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Incorrect syntax near ','. [message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Incorrect syntax near ','. ) ) 

Open in new window


So it seems my sql query is junk and I need to find a way to make it work with this driver =\
0
Anthony PerkinsCommented:
>>Incorrect syntax near ','<<
You are missing an END before the ','.  Your SQL Statement should look like this:
SELECT  CASE WHEN (STOCKWH.MFG) IS NULL THEN ' '
             ELSE STOCKWH.MFG
        END,
        STOCK.PARTNUMBER AS 'Part Number',
        STOCK.DESCRIPTN AS 'Description',
        STOCK.QTY_INSTOCKCOND AS 'Condition',
        STOCKWH.MFG AS 'Mfg Code',
        STOCKWH.QTY AS 'Qty'
FROM    [stock]
        INNER JOIN STOCKWH ON STOCK.PARTNUMBER = STOCKWH.PARTNUMBER
WHERE   STOCKWH.QTY > 0
ORDER BY STOCK.PARTNUMBER
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
E J PopeAuthor Commented:
You sir are the man. Thank you!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.