Jump to content

mssql and php query issues


kris1988edwards

Recommended Posts

Hello,

 

I am trying to run a report as per the below mssql query:

 

$query = "SELECT tblWJCItem.AddedDescription, tblWJC.WJCPrefix, tblWJC.WJCNo, tblWJCItem.MaterialName, tblStockFamily.StockFamily, tblWJCItem.WeightToSend, tblWJC.DateCreated, tblWJC.WJCStatusID FROM tblWJC INNER JOIN tblCustomer ON tblWJC.CustomerID = tblCustomer.CustomerID INNER JOIN tblWJCStockStatus ON tblWJC.WJCStockStatusID = tblWJCStockStatus.WJCStockStatusID INNER JOIN tblStockStatus ON tblWJC.WJCID = tblStockStatus.WJCID LEFT OUTER JOIN tblWJCProductLine ON tblWJC.WJCID = tblWJCProductLine.WJCID
LEFT OUTER JOIN tblWJCStockItem ON tblWJCProductLine.WJCProductLineID = tblWJCStockItem.tblWJCStockItem INNER JOIN tblStockFamily ON tblWJCItem.ProductFamilyID = tblStockFamily.StockFamilyID WHERE tblCustomer.CustomerName = 'NAME' AND tblWJCStockStatus.WJCStockStatus <> 'Stock Usage Confirmed' ORDER BY tblWJC.WJCID";

and then fetch the results by the following php code:

 

$result = sqlsrv_query($conn, $query);
while($row = sqlsrv_fetch_object($result)){ 
echo $row->AddedDescription .",".$row->WJCPrefix .",".$row->WJCNo.",".$row->MaterialName.",".$row->StockFamily.",".$row->WeightToSend.",".$row->DateCreated->format('d-m-Y').",".$row->WJCStatusID ."<br />";
}

The connection to the database does get established but no results come through, i've got error reporting on in my php and the following message gets given:

Warning: sqlsrv_fetch_object() expects parameter 1 to be resource, boolean given in C:\inetpub\wwwroot\kris\abs\test\rollsroyce.php on line 31

Line 31 is the while($row = sqlsrv_fetch_object($result))

 

Can anyone help with sorting this out its really starting to annoy me now. .

 

Link to comment
Share on other sites

i looked at your horrifically verbose query (you need to use better table names, column names, use aliases in the query and some white-space to format the query) and there's an obvious error in a column reference, so, i doubt the exact query you posted here, that's producing a query error, is the one that you ran directly against your database server.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.