SQL Server Query (being echo'd)
Posted: Mon Feb 08, 2010 4:37 am
I am using the following code:
In the table where i want to echo the count i call it by:
I get the following errors:
PHP Warning: mssql_query() [<a href='function.mssql-query'>function.mssql-query</a>]: Query failed in /var/www/helpdesk-dev/statistics.php on line 89
PHP Notice: PHP Warning: mssql_result(): supplied argument is not a valid MS SQL-result resource in /var/www/helpdesk-dev/statistics.php on line 93, referer: http://helpdesk:90/statistics.php
---------------------------------------------------------------------------------------------------------
If i run the query bit in SQL Server:
It works fine.....
But i can't get it to work in my table...
Any ideas?
Code: Select all
[color=#FF0000]LINE89:[/color] $slamettoday = mssql_query("SELECT COUNT(c.id) as slatoday FROM faultlog as c INNER JOIN contact ON c.contid=contact.id WHERE logged>DATEADD(DAY,-1,GETDATE()) AND response<datediff(hour,logged,(SELECT TOP 1 date FROM notes WHERE id=c.id AND id_prefix=c.id_prefix ORDER BY date ASC))". $db);
[color=#FF0000]LINE93:[/color] $slamettoday=mssql_result($query,0,'slatoday');Code: Select all
<?echo $slamettoday . "%" ?>PHP Warning: mssql_query() [<a href='function.mssql-query'>function.mssql-query</a>]: Query failed in /var/www/helpdesk-dev/statistics.php on line 89
PHP Notice: PHP Warning: mssql_result(): supplied argument is not a valid MS SQL-result resource in /var/www/helpdesk-dev/statistics.php on line 93, referer: http://helpdesk:90/statistics.php
---------------------------------------------------------------------------------------------------------
If i run the query bit in SQL Server:
Code: Select all
SELECT COUNT(c.id) as slatoday FROM faultlog as c INNER JOIN contact ON c.contid=contact.id WHERE logged>DATEADD(DAY,-1,GETDATE()) AND response<datediff(hour,logged,(SELECT TOP 1 date FROM notes WHERE id=c.id AND id_prefix=c.id_prefix ORDER BY date ASC))But i can't get it to work in my table...
Any ideas?