gpt4 book ai didi

php - 警告 : mysql_num_rows() expects parameter 1 to be resource, null 中给出

转载 作者:行者123 更新时间:2023-11-29 13:18:58 25 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





mysql_fetch_array()/mysql_fetch_assoc()/mysql_fetch_row()/mysql_num_rows etc... expects parameter 1 to be resource

(31 个回答)


8年前关闭。




我正在尝试删除行并且它正在删除,但我遇到了错误。您能否查看代码并指导我解决此问题:
错误:
警告:mysql_num_rows() 期望参数 1 是资源,在 上的/home/fqaotczz/public_html/dev/Seller/delete_exec.php 中给出 bool 值第 25 行

 CODE
<?php

//Get data from Session
session_start();
$userid = $_SESSION['userid'];

//Get data from URL
$table = $_GET['table'];
$favprod = $_GET['favprod'];
$page = $_GET['page'];

//Include database connection details
require_once('../connection.php');
include '../Database.class.php';
$dbe_obj = new Database_Executer();

//Create query
$query = "DELETE FROM SELLER_PRODUCT WHERE SELLER_PRODUCT.USER_ID = '$userid' AND SELLER_PRODUCT.PRODUCT_ID = '$favprod'";

$result = $dbe_obj->delete_query_executer($query) or die($query."<br/>".mysql_error());

//Check whether the query was successful or not
if($result){
***if(mysql_num_rows($result) > 0) {***
//Delete Successful

$member = mysql_fetch_assoc($result);
//$first_name = $member["FIRST_NAME"];
//$last_name = $member["LAST_NAME"];
$message = "Record deleted successfully.";
header("Location: $page?message=".$message);

}
else {
//Login failed

$message = "Record could not be deleted.";
header("Location: $page?message=".$message);
}
}
else {
die("Query failed !");
}

?>

最佳答案

你必须使用这个http://cz1.php.net/manual/en/function.mysql-affected-rows.php

//Check whether the query was successful or not 
if($result){
***if(mysql_affected_rows($result) > 0) {***
//Delete Successful

关于php - 警告 : mysql_num_rows() expects parameter 1 to be resource, null 中给出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21112936/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com