mysql_fetch_array error

i keep on getting this message :

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\Prod-MEDICT\print\lapLogAgensi.php on line 65

is it bcoz of my query ? my query is like :-

$query = “select t1.logno AS LOG_NO,
(select t2.status from call_status as t2 where t1.idStatus = t2.idCallStatus) AS STATUS,
(select t3.nama from user as t3 where t1.idUser = t3.idUser) AS NAMA,
(select t4.kementerian from kementerian as t4, user as t3 where t3.idKementerian = t4.idKementerian) AS KEMENTERIAN,
(select t5.agensi from agensi as t5, user as t3 where t3.idAgensi = t5.idAgensi) AS AGENSI,
(select t3.noPej, t3.noPejSuffix from user as t3) AS NO_PEJ,
(select t3.noHP, t3.noHPSuffix from user as t3) AS NO_HP,
(select t3.email from user as t3) AS EMAIL,
(select t6.problemcat from call_problem_cat as t6 where t1.idcallproblemcat = t6.idcallproblemcat) AS KATEGORI_KETERANGAN_MASALAH,
(select t1.keterangan AS KATEGORI_KETERANGAN_MASALAH, t1.penyelesaian AS PENYELESAIAN from call_log as t1),
(select t7.namakump from team as t7 where t1.idGroup = t7.idteam) AS GROUP_ASSIGNEE,
(select t3.nama from user as t3, assignee as t8 where t8.idAssignee = t3.idUser) AS GROUP_ASSIGNEE,
t1.closedDate AS CLOSED_DATE from call_log as t1
AND YEAR(call_log.createddate) = $tahun
order by idCallLog ASC”;

pls help me… TQ

Hello,

If you could, please provide the rest of your code that handles this query. Even though the error does have something to do with your query code, it might have something to do with how you are using your query in your code. Please provide all of your code that handles your query.

NOTE: please make sure that if your code contains your database credentials, either ***** them out, or just simply don’t include it.

Cheers!

TQVM for your concern… here i attach my code …

<?php include "../library/conn.php"; if(isset ($_GET['tahun'])) { $tahun = $_GET['tahun']; } $filename = "agensi.xls"; header("Content-Type: application/vnd.ms-excel"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("content-disposition: attachment;filename=$filename"); header("Pragma: no-cache"); header("Expires: 0"); ;?> <?php $query = "select t1.logno AS LOG_NO, (select t2.status from call_status as t2 where t1.idStatus = t2.idCallStatus) AS STATUS, (select t3.nama from user as t3 where t1.idUser = t3.idUser) AS NAMA, (select t4.kementerian from kementerian as t4, user as t3 where t3.idKementerian = t4.idKementerian) AS KEMENTERIAN, (select t5.agensi from agensi as t5, user as t3 where t3.idAgensi = t5.idAgensi) AS AGENSI, (select t3.noPej, t3.noPejSuffix from user as t3) AS NO_PEJ, (select t3.noHP, t3.noHPSuffix from user as t3) AS NO_HP, (select t3.email from user as t3) AS EMAIL, (select t6.problemcat from call_problem_cat as t6 where t1.idcallproblemcat = t6.idcallproblemcat) AS KATEGORI_KETERANGAN_MASALAH, (select t1.keterangan AS KATEGORI_KETERANGAN_MASALAH, t1.penyelesaian AS PENYELESAIAN from call_log as t1), (select t7.namakump from team as t7 where t1.idGroup = t7.idteam) AS GROUP_ASSIGNEE, (select t3.nama from user as t3, assignee as t8 where t8.idAssignee = t3.idUser) AS GROUP_ASSIGNEE, t1.closedDate AS CLOSED_DATE from call_log as t1 AND YEAR(call_log.createddate) = $tahun order by idCallLog ASC";

$bil = 0;
$result = mysql_query($query);
while($row = mysql_fetch_array($result)){
$logno = $row[0];
$idStatus = $row[1];
$nama = $row[2];
$idKementerian = $row[3];
$idAgensi = $row[4];
$nopejSuffix = $row[5];
$nopej = $row[6];
$noHPSuffix = $row[7];
$noHP = $row[8];
$email = $row[9];
$problemcat = $row[10];
$keterangan = $row[11];
$penyelesaian = $row[12];
$idGroup = $row[13];
$idAssignee = $row[14];
$closedDate = $row[15];
$bil = $bil+1;

?>

<?php } ?>
BIL
LOG NO
STATUS
NAMA
KEMENTERIAN
AGENSI
NO PEJ
NO HP
EMAIL
KATEGORI/KETERANGAN MASALAH
PENYELESAIAN
GROUP/ASSIGNEE
CLOSED DATE
<?php echo $bil;?>
<?php echo $logno;?>
<?php echo $idStatus;?>
<?php echo $nama;?>
<?php echo $idKementerian;?>
<?php echo $idAgensi;?>
<?php echo $nopejSuffix."".$nopej;?>
<?php echo $noHPSuffix."".$noHP ;?>
<?php echo $email;?>
<?php echo $problemcat."".$keterangan;?>
<?php echo $penyelesaian;?>
<?php echo $idGroup."".$idAssignee;?>
<?php echo $closedDate;?>

This will get you your query error. The issue is that your query is failing and giving you a boolean value of false. When you pass that to mysql_fetch_array (which expects a mysql result object) you get that error change your query line to this and you should get the error with your SQL query.

[php]$result = mysql_query($query) or die(mysql_error());[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service