Jump to content

[SOLVED] problem with mysqli_fetch_array


will35010

Recommended Posts

I'm trying to pull the results of tickets submitted for the last hour. It gives me this error:

 

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /var/www/test/email.php on line 30

 

<?php
/*
This script is for taking newly submitted tickets and emailing them to maintenance
Author: Will Morris
Date: June 23, 2009
Revision Date:  
*/

//error reporting for testing purposes
error_reporting(E_ALL);
ini_set("display_errors", "on");

//Database Settings
$dbhost = "localhost"; 
$dbuser = "*****"; 
$dbpass = "*****"; 
$dbname = "workorder";

//MySql Connection
$conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname) or die        
                     ('Error connecting to mysql');
                     
//Set varibles for the current date and time to determine what tickets are emailed
$currentDate = date('Y-m-d');
$currentTime = date('G-i-s');   
$lastHour = date('G') - 1;                  
                     
//MySql query to get tickets for the current day and last hour
$result = mysqli_query($conn, "SELECT num, fname, lname, dep, desc, recp, time, date FROM tickets WHERE date = '$currentDate' AND time = '$lastHour'");

while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
   echo $row['num'];
}


?>

Link to comment
https://forums.phpfreaks.com/topic/163434-solved-problem-with-mysqli_fetch_array/
Share on other sites

There may be a problem with the query, which then returns false.

 

Check to see if there is an error.

 

$result = mysqli_query($conn, "SELECT num, fname, lname, dep, desc, recp, time, date FROM tickets WHERE date = '$currentDate' AND time = '$lastHour'") or die("Error: ".$conn->error);

Archived

This topic is now archived and is closed to further replies.

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