Kryllster Posted September 5, 2014 Share Posted September 5, 2014 I have some code I used to have in mysql and now im trying to convert to mysqli and I cant seem to find out what the problem is. <?php $username = $_SESSION['username']; // Connect to server and select databse. include "db_connect.php"; include "db_config.php"; // items tables selection $sql = mysqli_query($my_database,"SELECT * FROM items_tbl WHERE level = '$account_info[player_level]' ORDER BY rand()"); //$result = mysqli_query($my_database,$sql); // Put info into array (This Works) while($item = mysqli_fetch_assoc($sql)){ //stats $items_id['itemid'] = $item['itemid']; $items_id['Level'] = $item['Level']; $items_id['name'] = $item['name']; $items_id['min_str'] = $item['min_str']; $items_id['min_int'] = $item['min_int']; $items_id['min_dex'] = $item['min_dex']; $items_id['type'] = $item['type']; $items_id['min_dmg'] = $item['min_dmg']; $items_id['max_dmg'] = $item['max_dmg']; $items_id['phys_defense'] = $item['phys_defense']; $items_id['mag_defense'] = $item['mag_defense']; } ?> here is the error im getting: Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given Quote Link to comment https://forums.phpfreaks.com/topic/290864-new-to-mysqli-need-help-with-script-pls/ Share on other sites More sharing options...
mac_gyver Posted September 5, 2014 Share Posted September 5, 2014 the error you are getting is very common. see the following link for what it means and how to find what's causing it - http://forums.phpfreaks.com/topic/273121-readme-php-resources-faqs/?do=findComment&comment=1428660 Quote Link to comment https://forums.phpfreaks.com/topic/290864-new-to-mysqli-need-help-with-script-pls/#findComment-1490025 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.