Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/290864-new-to-mysqli-need-help-with-script-pls/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.