snivek Posted January 22, 2007 Share Posted January 22, 2007 This query is blowing up and I do not know why[code]<?php$sql = "SELECT DateDiff(\"d\", (SELECT TOP 1 dhcp_log_date FROM dhcp_log ORDER BY dhcp_log_date ASC), GetDate())";$result = mssql_query($sql);?>[/code]Here is the query PRINTED, and the error.SELECT DateDiff("d", (SELECT TOP 1 dhcp_log_date FROM dhcp_log ORDER BY dhcp_log_date ASC), GetDate())Warning: mssql_query() [function.mssql-query]: message: Invalid parameter 1 specified for datediff. (severity 15) in E:\DHCPLogs\index.php on line 48The same query works fine from SQL Mgmt Studio.Also - the following query executes without any prob from php.[code]<?php$sql = "SELECT TOP 1 dhcp_log_date FROM dhcp_log ORDER BY dhcp_log_date ASC"?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/35215-select-within-a-select/ Share on other sites More sharing options...
MCP Posted January 25, 2007 Share Posted January 25, 2007 try this maybe?[code]<?php$sql = "SELECT DateDiff('d', (SELECT TOP 1 dhcp_log_date FROM dhcp_log ORDER BY dhcp_log_date ASC), GetDate())";$result = mssql_query($sql);?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/35215-select-within-a-select/#findComment-168650 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.