d_governor Posted December 1, 2012 Share Posted December 1, 2012 $sql = ("select * from MainAdmin WHERE security = '$username' and password = '$password'"); $Userquery = mysql_query($sql); $Userfetch = mysql_fetch_array($Userquery); if (mysql_num_rows($Userquery)==0 ) { echo "<font color=#ff0000><Center>**Failed Login**</Center></font>"; } if (mysql_num_rows($Userquery) != 0 ) { $_SESSION['logged_in'] == true; $_SESSION['Security'] = $Userfetch['Security']; $_SESSION['Name'] = $Userfetch['Name']; if($Userfetch['status'] == 'MainAdmin' || 'Admin') { $Page = 'adminP.php'; } Quote Link to comment https://forums.phpfreaks.com/topic/271452-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-in-c/ Share on other sites More sharing options...
d_governor Posted December 1, 2012 Author Share Posted December 1, 2012 I'm having this problem.. Don't know what to do.... Please Help Quote Link to comment https://forums.phpfreaks.com/topic/271452-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-in-c/#findComment-1396710 Share on other sites More sharing options...
Pikachu2000 Posted December 1, 2012 Share Posted December 1, 2012 That error indicates your query failed to execute. echo mysql_error to see why. Quote Link to comment https://forums.phpfreaks.com/topic/271452-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-in-c/#findComment-1396714 Share on other sites More sharing options...
Jessica Posted December 1, 2012 Share Posted December 1, 2012 See the link in my signature on debugging SQL Quote Link to comment https://forums.phpfreaks.com/topic/271452-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-in-c/#findComment-1396758 Share on other sites More sharing options...
Andy123 Posted December 1, 2012 Share Posted December 1, 2012 (edited) Your query is failing, and you are trying to hand $Userquery off to mysql_fetch_array() as a resource. However, mysql_query() returns FALSE on failure, hence why $Userquery is FALSE. That is why you get this warning; you are giving a boolean value where a resource value is expected - exactly as the warning says. You should check if the query was executed successfully, e.g.: $Userquery = mysql_query($sql); if ($Userquery) { // Query executed successfully if (mysql_num_rows($Userquery) > 0) { // At least one row returned - now we can fetch it/them while ($row = mysql_fetch_array($Userquery) { // Do something } } else { // No rows returned } } else { // Error executing query } Edited December 1, 2012 by Andy123 Quote Link to comment https://forums.phpfreaks.com/topic/271452-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-in-c/#findComment-1396765 Share on other sites More sharing options...
d_governor Posted December 1, 2012 Author Share Posted December 1, 2012 Alright guys. I've fixed it.. Quote Link to comment https://forums.phpfreaks.com/topic/271452-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-in-c/#findComment-1396766 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.