Using FPDF with webhost

Thanks for trying :smile:

Ok

Are all the field datatypes Strings?

Try casting

$pdf->Cell(20,12,{(string)$column},1);

No, some are just 1 digit

It doesn’t do anything adding the (string)

I keep on getting the empty query

Putting in your line with the (string) gives me a server error

Sorry, that’s no good.
Try

foreach($row as $column)
   $column = (string)$column;
		$pdf->Cell(20,12,$column,1);

That doesn’t change anything. I think there’s something wrong with my connecting to the database but I just can’t see what.

At least, with this, I don’t get the server error

Maybe replacing the “everything” - which is likely returning both numeric and associative keys in the result object - with the field names

$query = "SELECT col_one, col_two, etc from inc"; 
// how many and whichever ones you want

That didn’t change anything either

OK, fightin’ time

temporarily try

$pita = array();
foreach($result as $row) {
//	$pdf->SetFont('Arial','',12);	
//	$pdf->Ln();
	foreach($row as $column) {
    $pita[] = $column;
//		$pdf->Cell(20,12,$column,1);
    }
}
var_dump($pita);
exit;
$pdf->Output();
?>

It gives me this:
array(0) { }

Like I said your inc table is empty.

The table might have rows in it on your local but not on the server. The server uses a separate database.

If you try to run that query on the server outside of your script then what does it give you?

I promise you it isn’t, here’s a screen capture:

I have a ‘contents’ php that lists that table perfectly using the same connection details

It’s only with FPDF that I have this problem connecting.

How do I do this? - run query on the server outside of the script?

There is no connection whatever between the database connection and FPDF.

It would be like saying that that your car refuses to start on Friday - it worked on Tuesday, Wednesday and Thursday so Friday must be the reason it wont start.

Run this and post what it prints.

<?php

DEFINE ('DB_USER', 'root');
DEFINE ('DB_PASSWORD', 'xxx');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', 'finalpost');

$conn = mysqli_connect DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die
('Could not connect to MySQL: ' . mysqli_connect_error() );

$query = "SELECT * from inc"; 
$result = mysqli_query($conn, $query) or die(mysqli_error());


printf('<p>Rows: %u</p>',$result->num_rows);