Using Images in FPDF

I've been using a few FPDF routines in my project for years without a hitch. I've also used the Image function to successfully place a couple of PNG flags in the document. Now I'm trying to place a few extra smaller flags in a few places in the document. I'm using almost the exact same code which renders them fine and yet I can't get it working. Can someone take a look at the code snippets below and see if they can see anything wrong please?

Firstly, this is how I call the flags with success earlier in the document:
if($grph==1) {
	$this->Image("images/flags/".$data['home_cc'].".png", 15, $y, 7, 3.5);
	$this->Image("images/flags/".$data['host_cc'].".png", 15, $y+5, 7, 3.5);

Open in new window

No problems there. Then I try to call almost the same code within a function which prints a line at a time which I call from a FOREACH loop. The loop looks like this:
foreach($data['pre_tax_remuneration'] as $row) {
	if($row[3]==1) $fl=$data['home_cc']; else $fl=$data['host_cc'];
	$this->Breakdown_Values($row[0], $row[$curr+1], $x1, $fl);

Open in new window

$row[3] is just a two letter string of the country and I'#ve checked that that is making it through to the function correctly. So, the function is:
function Breakdown_Values($title, $value, $x, $fl) {
global $c;
$this->SetTextColor($c['txt_2']['r'], $c['txt_2']['g'], $c['txt_2']['b']);
	$this->SetTextColor($c['txt_1']['r'], $c['txt_1']['g'], $c['txt_1']['b']);
	if($fl!=0) {
		$this->Image("images/flags/".$fl.".png", $x+1, $y, 3, 2);

Open in new window

$c is just an array of a colour. I've tried playing about with the $x and $y values just to get it placed somewhere in the document but it never seems to appear.

Can anyone spot why? This is really bugging me ebcause I've now spent over two hours trying everything I can think of but with no success.

The manual for the FPDF is here and I use version 1.6.

I greatly appreciate any help/input.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

worldofwiresAuthor Commented:
Cracked it. It was my IF statement. I changed it to:
	if(!is_numeric($fl)) {
		$this->Image("images/flags/".$fl.".png", $x+1, $y, 3, 2);

Open in new window

and it works. Not sure why though but it's sorted. I was passing a 0 value for teh rows where I didn't want a flag and a string when I did so I guess there is a lesson there about mixing up your variables.

I am going to rewrite the function call so I don't have to specify the the 0 when I don't want flags. So it will then look like:
function Breakdown_Values($title, $value, $x, $fl=NULL) {

Open in new window

function Breakdown_Values($title, $value, $x, $fl=0) {

Open in new window

to keep my !is_numeric IF stament working. Anyone want to advise/opine on best practises on this front?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.