CMK08 Posted October 21, 2008 Share Posted October 21, 2008 Hello there, Last night I worked on this script on my mac os x and everything was working beautifully. This morning I came to work to test the same script on a windows machine - apache 2.2.8, php 5.2.6, mysql 5.0.51b - and now I get this warning: Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\wamp\www\downloads\zipplet.php on line 19 Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, boolean given in C:\wamp\www\downloads\zipplet.php on line 27 Here is the code: <?PHP require_once('../connect.php'); //initiates the array to build form $fileList2 = array(); //this is a place holder for data coming from log in $user_id=2; //select query to display only data belonging to current user $qry = "Select user_name, rpt_name FROM data_reports_users where user_id=$user_id"; $r = mysqli_query($dbc,$qry); //retrieve data from query result and put it in $fileList2 while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)){ $fileList2[] = $row['rpt_name']; } mysqli_free_result($r); mysqli_close($dbc); Any ideas? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/129396-solved-why-warning-mysqli_fetch_array-expects-parameter-1-to-be-mysqli_result/ Share on other sites More sharing options...
rhodesa Posted October 21, 2008 Share Posted October 21, 2008 your query is failing, try replacing this: $r = mysqli_query($dbc,$qry); with $r = mysqli_query($dbc,$qry) or die("Error: ".mysqli_error($dbc)); Quote Link to comment https://forums.phpfreaks.com/topic/129396-solved-why-warning-mysqli_fetch_array-expects-parameter-1-to-be-mysqli_result/#findComment-670828 Share on other sites More sharing options...
CMK08 Posted October 21, 2008 Author Share Posted October 21, 2008 Cool! The error reads: "no database selected". It turned out that my "connect.php" file didn't have a database defined. Thank you very much! I will try to always use that line from now on! CMK08 Quote Link to comment https://forums.phpfreaks.com/topic/129396-solved-why-warning-mysqli_fetch_array-expects-parameter-1-to-be-mysqli_result/#findComment-670834 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.