Mysqli_fetch_assoc()给出错误。无法调试 [英] Mysqli_fetch_assoc() gives an error. Can't debug

查看:413
本文介绍了Mysqli_fetch_assoc()给出错误。无法调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里我要做的是计算club_member表中每个俱乐部会员的生日和今天的日期(以月为单位)之间的差异。



我尝试了什么:



我实现了以下代码。但是当我执行它后,出现错误 警告:mysqli_fetch_assoc()期望参数1为mysqli_result,在第228行的C:\ xampp \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

Here what I'm trying to do is calculate the difference between the birthdate and today's date, in months, of each club member of the club_member table.

What I have tried:

I implemented the below code for that. But when I execute it following error appears "Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\index33.php on line 228"

$row = mysqli_fetch_assoc($resulttime); //Line 228



第228行显示在下面的代码中




The line 228 is shown in the code below

<?php
      $procedure = "  
      CREATE PROCEDURE selectMembers()  
      BEGIN  
      SELECT * FROM club_member ORDER BY CIRP_ID DESC;  
      END;  
      ";  
      if(mysqli_query($conn, "DROP PROCEDURE IF EXISTS selectMembers"))  
      {  
           if(mysqli_query($conn, $procedure))  
           {    
		   		$query = "CALL selectMembers()";  
                $result = mysqli_query($conn, $query); 
				while($row = mysqli_fetch_array($result))  
                     {  
						  			
						  $now = time();
					 	  $timequery = "SELECT bday FROM club_member WHERE CIRP_ID='".$row["CIRP_ID"]."'";
						  $resulttime = mysqli_query($conn, $timequery);
						   
						  $row = mysqli_fetch_assoc($resulttime); //Line 228
						  $then = strtotime($row["bday"]);
						  $difference = ($now - $then);
						  $months = floor($difference / (60*60*24*30) );
						  
						  $sqlinsert = "INSERT INTO `club_member`(`Months`) VALUES ('".$months."')";
			
						  $resultinsert = mysqli_query($conn,$sqlinsert);			

                     } 
		   }
	  }
?> 







这里我试图在while循环中为$ row分配$ row的新值,该值在$ row的原始值上运行。我认为这是造成这个错误的原因。但我不知道如何进行计算并填充该特定记录的表格单元格。如果你能以任何其他方式告诉我,那将是很棒的。请帮忙:')




Here I'm trying to assign new values for $row inside the while loop which runs on original value of $row. I think that's what's causing this error. But I have no idea of doing the calculation and filling that table cell of that specific record otherwise. If you can show me any other way, that would be great. Please help :')

推荐答案

row = mysqli_fetch_assoc(
row = mysqli_fetch_assoc(


resulttime); // 第228行
resulttime); //Line 228



第228行显示在下面的代码中




The line 228 is shown in the code below

<?php
      


procedure =
CREATE PROCEDURE selectMembers()
BEGIN
SELECT * FROM club_member ORDER BY CIRP_ID DESC;
END;
;
if(mysqli_query(
procedure = " CREATE PROCEDURE selectMembers() BEGIN SELECT * FROM club_member ORDER BY CIRP_ID DESC; END; "; if(mysqli_query(


这篇关于Mysqli_fetch_assoc()给出错误。无法调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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