vbcoach Posted March 9, 2014 Share Posted March 9, 2014 All of a sudden I am getting this error. Just started - no change in code that I am aware of. Googling this error is not helping much. Can anyone assist? Warning: sqlsrv_fetch_array() expects parameter 1 to be resource, boolean given in... Link to comment https://forums.phpfreaks.com/topic/286837-warning-sqlsrv_fetch_array-expects-parameter-1-to-be-resource-boolean-given-in/ Share on other sites More sharing options...
mac_gyver Posted March 9, 2014 Share Posted March 9, 2014 it means your query failed due to an error and returned a false value or you could be using a wrong variable name or there's a problem in your code and this error was always occurring but was hidden and what changed is that the php error_reporting level got changed. does your code that is running the query contain any error checking logic in it so that you would know if the query is producing an error, and if so, what is the output from sqlsrv_errors()? Link to comment https://forums.phpfreaks.com/topic/286837-warning-sqlsrv_fetch_array-expects-parameter-1-to-be-resource-boolean-given-in/#findComment-1471940 Share on other sites More sharing options...
vbcoach Posted March 9, 2014 Author Share Posted March 9, 2014 Warning: sqlsrv_fetch_array() expects parameter 1 to be resource, boolean given in\\WDP\DFS\30\0\8\8\3049380880\user\sites\3395336.site\www\database.php on line 46 Line 46 from database.php is: //return mssql_fetch_assoc($resource); return sqlsrv_fetch_array($resource, SQLSRV_FETCH_ASSOC); This script has been working for years. Just stopped last night. Link to comment https://forums.phpfreaks.com/topic/286837-warning-sqlsrv_fetch_array-expects-parameter-1-to-be-resource-boolean-given-in/#findComment-1471946 Share on other sites More sharing options...
mac_gyver Posted March 9, 2014 Share Posted March 9, 2014 your reply above doesn't provide any additional information and contains nothing i asked about. without even seeing your code that runs the query, i can tell it does not have any error checking logic in it, and the php error you are getting is a follow-on error because you allowed your code to try to fetch data from a query that failed with an error of some kind. it doesn't matter how long your code may have previously worked. it requires finding out why it is failing now in order to find the cause to fix it. until you add some logic to your code that tells you the output from sqlsrv_errors() when the query fails, you will never discover what is causing the problem. Link to comment https://forums.phpfreaks.com/topic/286837-warning-sqlsrv_fetch_array-expects-parameter-1-to-be-resource-boolean-given-in/#findComment-1471948 Share on other sites More sharing options...
vbcoach Posted March 9, 2014 Author Share Posted March 9, 2014 There are sqlsvr_errors() written in the code. However this is still what I am getting. Any suggestions? Link to comment https://forums.phpfreaks.com/topic/286837-warning-sqlsrv_fetch_array-expects-parameter-1-to-be-resource-boolean-given-in/#findComment-1471957 Share on other sites More sharing options...
vbcoach Posted March 10, 2014 Author Share Posted March 10, 2014 DISREGARD! Found the answer. redundant statement in the sql query itself. thanks to all who posted! Link to comment https://forums.phpfreaks.com/topic/286837-warning-sqlsrv_fetch_array-expects-parameter-1-to-be-resource-boolean-given-in/#findComment-1471968 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.