Click here to Skip to main content
15,893,622 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
PHP
session_start();
include('../config.php');


//connect to the database
mysql_select_db("syahadmin");

//query the database
$query = mysql_query("SELECT * FROM staff where staff_name = 'Aidia'");

//fetch the results /convert results into an array   //this is happening
		WHILE ($rows = mysql_fetch_array($query)) :
		//do this
		   $staff_name =$rows['staff_name'];
		   $staff_id =$rows['staff_id'];
		   $staff_email =$rows['staff_email'];
		   $staff_telno =$rows['staff_telno'];
		   $staff_address =$rows['staff_address'];
		   $staff_district =$rows['staff_district'];
		   $staff_poscode =$rows['staff_poscode'];
		   $staff_username =$rows['staff_username'];
		   $staff_password =$rows['staff_password'];
		   $staff_picture =$rows['staff_picture'];

require('mysql_table.php');

class PDF extends PDF_MySQL_Table
{
function Header()
{
	//Title
	$this->SetFont('Arial','',18);
	$this->Cell(0,6,'Staff Information',0,1,'C');
	$this->Ln(10);
	//Ensure table header is output
	parent::Header();
}
}


$pdf=new PDF();                                     
$pdf->AddPage();
//First table: put all columns automatically
$pdf->Table('SELECT `staff_name`, `staff_id`,`staff_email`,`staff_telno`,`staff_address`,`staff_poscode`,`staff_district`,`staff_state`
 from staff order by `staff_name`');
$pdf->AddPage();
//Second table: specify 3 columns
$pdf->AddCol('staff_name',43,'','C');
$pdf->AddCol('`staff_id`,',40,'staff','C');
$pdf->AddCol('staff_email',40,'','C');
$pdf->AddCol('staff_telno',40,'','C');
$pdf->AddCol('staff_address',40,'','C');
$pdf->AddCol('staff_poscode',40,'','C');
$pdf->AddCol('staff_district',40,'','C');
$pdf->AddCol('staff_state',40,'','C');
$prop=array('HeaderColor'=>array(255,150,100),
			'color1'=>array(210,245,255),
			'color2'=>array(255,255,210),
			'padding'=>2);
$pdf->Table('select staff_name,  staff_id, staff_email, staff_telno, staff_address, staff_poscode, staff_district, staff_state, 
 from staff order by staff_name limit 0,10',$prop);

//$pdf->Output("C:\Users\John\Desktop/somename.pdf",'F'); 


$pdf->Output($downloadfilename.".pdf"); 
header('Location: '.$downloadfilename.".pdf");
 endwhile;
?>
Posted
Updated 12-May-15 15:09pm
v2
Comments
CHill60 12-May-15 9:16am    
This is just a code dump - your question is not clear
Mohibur Rashid 12-May-15 21:14pm    
You dumped your bunch of code without any proper question.
Here is few more information that is missing
1. What line
2. What is the detail of the actual error?

Your message says mysql_fetch_array expects parameter to be a resource not boolean.
Which means your mysql_query is failing. Probably query error. It can be syntax error or your fields name are invalid. Why don't you find it out and fix it.

1 solution

When you look at the documentation for mysql_query[^] you see that it returns FALSE in case the query failed to execute successfully.

And obviously mysql_fetch_array can't do anything with an input that is just FALSE.

So, you need to:

1) Analyze why your query failed and correct it. Probably you've written either the table name or column name incorrectly.

2) For good practise you should always check the result of mysql_query for being FALSE and in that case take some helpful actions, like logging the error to a log file or sending you a notification email with the query string of the failed query for your easy reference.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900