Jump to content

New to mysqli need help with script pls?


Kryllster

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.