: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in
C:\xampp\htdocs\sites\admin_panel\admin\base\load_data.php
<prev>this load_data.php file </prev>
What I have tried:
<pre> <?php
//ADD lost _ item...
$query = "Select Max(item_id) From lost_items_table";
$returnD = mysql_query($query);
$result = mysql_fetch_assoc($returnD);
$maxRows = $result['Max(item_id)'];
if(empty($maxRows)){
$lastRow = $maxRows = 1001;
}else{
$lastRow = $maxRows + 1 ;
}
if(isset($_REQUEST['additem'])){
$item_id = $_REQUEST['item_id'];
$item_name = $_REQUEST['item_name'];
$description = $_REQUEST['description'];
$item_category = $_REQUEST['item_category'];
$pic = $_REQUEST['pic'];
if(!empty($item_id) && !empty($item_name) && !empty($item_category)){
if($maxRows){
$query = "Insert Into lost_items_table(item_id,item_name,description,item_category,pic) Values('$item_id','$item_name','$description','$item_category','$pic')";
mysql_query($query);
$errorMsg = "data Sucessfully Added.";
$query = "Select Max(item_id) From lost_items_table";
$returnD = mysql_query($query);
$result = mysql_fetch_assoc($returnD);
$maxRows = $result['Max(item_id)'];
if(empty($maxRows)){
$lastRow = $maxRows = 1001;
}else{
$lastRow = $maxRows + 1 ;
}
}
else{
$errorMsg = "Table is Empty.";
}
}
else{
$errorMsg = "Please! Enter in Empty Field.";
}
include("add_lostitem.php");
}
?>