Jump to content

mysqli_fetch_assoc()-was working fine


Go to solution Solved by requinix,

Recommended Posts

Had this working fine for weeks, then I come back and I get a warning.  There's a chance I could have "fat-fingered" something in the code...but I've gone through line by line and haven't found anything.  Maybe I'm  looking to hard...

 

Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in B:\Programs\wamp\www\hsa\rfi_list.php on line 29

 

 

thanks,

 

CB

<?php

	$conn = mysqli_connect("localhost","root","","hsa_project_hub");

	session_start(); 

	if(!$_SESSION['user_loginName']){
	header("location: index.php");
	}
	else {
		
?>



					
<?php
	//assign project ID value to local variable
	$project_id=$_SESSION['project_id'];
	
	
	$sql = "SELECT rfis.no,rfis.name,rfis.subject,rfis.issued_by,rfis.date_submit,rfis.needed_by,rfis.answered_by,rfis.date_returned,rfis.status\n"
		. "FROM projects,rfis\n"
		. "WHERE projects.project_id=rfis.id\n"
		. "AND project_id=$project_id";
		
		
		$result=mysqli_query($conn,$sql);
		$row=mysqli_fetch_assoc($result);
		$run = mysqli_query($conn, $sql);
		
		$i=0;
		
		
		
		
?>


<!DOCTYPE HTML>

<html>

	<head>
		<title>RFI List</title>

	<link href="hsastyle.css" rel="stylesheet">

	</head>
		<body>
			<div id="main_container">
				<p><em>version 1.0 beta</em></p>
		
				<div id="banner">
			
					<div id="logo">
						<img src="images/hsa-logo.jpg" alt=HSA logo>
					</div>
		
					
					<div id="logout"><H5><a href="logout.php">Log Out</a></H5></div>
					<div id="welcome"><h6>Welcome  <?php echo $_SESSION['firstName'];?></h6></div>
					<div id="project_name">		
						<strong><em><?php echo $_SESSION['projName']?></em></strong>
					</div>
					
				
					
			
						
				</div> <!--End Banner-->
				
				
			
			<div id="create">
				<FORM>
					<INPUT Type="BUTTON" Value="Create New RFI" Onclick="window.location.href='new_rfi.php'"> 
				</FORM>
			</div>		

			
			<div id="user_list">
				<FORM>
					<INPUT Type="BUTTON" Value="Back to Projects" Onclick="window.location.href='main.php'"> 
				</FORM>
				
			</div>	
			
			

			<div class="CSSTableGenerator" >	
				<table align="center">
		
					<tr align="center">
						<th>RFI No.</th>
						<th>Subject</th>
						<th>Issued by:</th>
						<th>Date Submitted</th>
						<th>Needed by:</th>
						<th>Answered by:</th>
						<th>Date Returned</th>
						<th>Status</th>
					</tr>
		
		<?php
			
			
		
			//assign values to local variables
			while($row=mysqli_fetch_array($run)){
				$rfi_id			=$row["no"];
				$rfiName		=$row["name"];
				$subject		=$row["subject"];
				$issued_by		=$row["issued_by"];
				$date_submit	=$row["date_submit"];
				$needed_by		=$row["needed_by"];
				$answered_by	=$row["answered_by"];
				$date_returned	=$row["date_returned"];
				$status			=$row["status"];
				$i++;
			
		?>
		
		
		
			
					
					<tr align="center">
				
						<td><a href="edit_rfi.php?id=<?php echo $rfi_id;?>"><?php echo $rfiName;?></a></td>
						<td><?php echo $subject;?></td>
						<td><?php echo $issued_by;?></td>
						<td><?php echo $date_submit;?></td>
						<td><?php echo $needed_by;?></td>
						<td><?php echo $answered_by;?></td>
						<td><?php echo $date_returned;?></td>
						<td><?php echo $status;?></td>
					</tr>
		<?php } ?>
				</table>
			</div><!-- end of table style
			
			
		</div> <!--End main container-->
			
			


	
			
			<!--<p id="copy_right">Heitkamp Swift Architects © 2015</p>-->			
				
		
		
		
		</body>
		
		
</html>
<?php } ?>
Link to comment
https://forums.phpfreaks.com/topic/298004-mysqli_fetch_assoc-was-working-fine/
Share on other sites

Why two calls to the same query?

 

        $result=mysqli_query($conn,$sql);

        $row=mysqli_fetch_assoc($result);

        $run = mysqli_query($conn, $sql);

       

  • Like 1
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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