:Mysql_fetch_assoc()期望参数1是资源,布尔值在 [英] : Mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in

查看:73
本文介绍了:Mysql_fetch_assoc()期望参数1是资源,布尔值在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

:mysql_fetch_assoc()要求参数1为资源,布尔值在
中给出C:\ xampp \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ .php



< prev>这个load_data.php文件< / prev>



我尝试过:



< pre> <?php

// ADD丢失_项目......



$ query =选择Max(item_id)来自lost_items_table;

$ returnD = mysql_query($ query);

$ result = mysql_fetch_assoc($ returnD);

$ maxRows = $ result ['Max (item_id)'];

if(空($ maxRows)){

$ lastRow = $ maxRows = 1001;

}否则{

$ 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 =插入lost_items_table(item_id,item_name,description,item_category,pic)值(' $ item_id','$ item_name','$ description','$ item_category','$ pic');

mysql_query($ query);

$ errorMsg =数据已成功添加。;



$ query =选择Max(item_id)来自lost_items_table;

$ returnD = mysql_query( $ query $;
$ result = mysql_fetch_assoc($ returnD);

$ maxRows = $ result ['Max(item_id)'];

if(empty($ maxRows)){

$ lastRow = $ maxRows = 1001;

}否则{

$ lastRow = $ maxRows + 1;

}

}

else {

$ errorMsg =表格是空的。;

}



}

else {

$ errorMsg =请在空场中输入。;

}



包括(add_lostitem.php);

}

?>

解决方案

query =选择Max(item_id)来自lost_items_table;


returnD = mysql_query(


query);

: 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");
}
?>

解决方案

query = "Select Max(item_id) From lost_items_table";


returnD = mysql_query(


query);


这篇关于:Mysql_fetch_assoc()期望参数1是资源,布尔值在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆