BinFrog 0 Newbie Poster

Hi everyone,

I have a SQL statement that runs just fine:

select
distinct(b.swName), a.mwBillToCompanyID, a.mwPaymentTerm, c.swCountry, d.mwCommCode, e.mwGRWarehouse, e.mwDongle,
case when e.mwExportStatus in ('B','C','EL','EUS') then
'End Use Required'
else
'No End Use Required'
end as 'EndUse', dbo.mw_Get_Distrib_Countries(a.mwBillToCompanyID) as 'Countries in Territory',
mwDiscountName, dbo.mw_Get_Distrib_Discounts(a.mwBillToCompanyID) as 'Discount Amounts'
from mw_office_info a
join sw_customer b on a.mwBillToCompanyID = swCustomerID
join sw_address c on b.swCustomerID = c.swObjectID and c.swObjectType = 'CUSTOMER'
join sw_Provider_Grp d on b.mwProviderGrpID = d.swProviderGrpID
join mw_Country e on c.swCountry = e.mwCountry
join sw_territory f on d.swTerritoryID = f.swTerritoryID
join sw_coverage on f.swTerritoryID = sw_coverage.swTerritoryID and f.swActive='1'
join sw_Region r on sw_coverage.swregionID =r.swRegionID
JOIN MW_DISCOUNT_PROGRAMS p on a.mwChannelDiscountID = p.mwDiscountID
JOIN MW_DISCOUNT_XREF dx ON dx.mwDiscountId = p.mwDiscountId
JOIN MW_DISCOUNT_RULES r1 ON dx.mwRuleId = r1.mwruleId
JOIN MW_RULES_XREF rx ON r1.mwRuleId = rx.mwRuleId
JOIN MW_DISCOUNT_CONSTRAINTS c1 ON c1.mwConstraintId = rx.MwConstraintId
where c.swCountry = 'AU'
and mwEffectiveFrom<=getDate() AND mwEffectiveTo>=getDate() AND
mwValue='95' AND mwConstraintName='ProductLineConstraint'
ORDER BY mwDiscountName


As you can see, the last 2 columns are from user-defined functions. For some reason PHP doesn't like the syntax though and it seems to think they are some sort of table. I have tried everything. I created a very simple UDF and tried to get PHP to display the results, and that works just fine. I tried embedding the SQL above into a stored procedure and calling the SP, but it fails. However, like I did with a simple UDF, I created a simple SProc which ran just fine. So for some reason it seems to just not like that SQL I wrote, even though the SQL itself runs just fine in Query Analyzer.

Any ideas how to get PHP to stop trying to do anything to the code and just let SQL handle it entirely? It's like PHP is trying to do some sort of error handling and code validation and it doesn't like that part of the SQL code for some reason.

Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.