Using FPDF with webhost

I’m completely clueless at this point. None of it makes sense.

So there’s something wrong with the nested foreach loops causing your problem

See if the following change makes any difference

foreach($result->fetch_object() as $row) {
	foreach($row as $column)
		echo $column . '<br>';
}
1 Like

Still the same:
Connected successfully
Rows: 75

I change the script to the following:
foreach($result->fetch_object() as $row) {
// foreach($row as $column)
echo $row . ‘
’;
}

and now I get the data :smile:

But only of one record.

Okay - try replacing fetch_object with fetch_all

No, the fetch_all doesn’t work at all

Don’t know where my head is at this morning (have got too used to using prepare statements and have forgotten how to retrieve data from a query).

foreach($result->fetch_row() as $row) {

It gives me the same result as before. Only for 1 row in a column

what you need to do is to figure out how to rewrite the foreach calls so that they actually retrieve the data. (My mind has gone blank on that at the moment)

Once you have done that then you just substitute that into your original page to generate the PDF.

Ok, thank you very much for all your help. At least, we’re getting something now. I’m afraid my head has gone flat, too :smile:

I think I see what I wasn’t seeing before (the caffeine is starting to kick in)

Despite the docs saying it is a “result object” it is more what I would call a “result handle”
That $result->fetch brings things a bit closer supports this interpretation.

That is, $result won’t work in a foreach

I’m also thinking fetch doesn’t return everything in one go, but more in “packets”

Try this

while($row = $result->fetch_assoc()) {
	foreach($row as $field => $column) {
		echo $field . " " . $column . '<br>';
     }
}
1 Like

I think I’ve really souped it all up. Just give me a minute to get it all back again
Right, I have my “Hello World” back
Let me see …

Wow! you’re a genius :smile:
It’s giving me ALL the info with the column names, but in a long list.
all the rows in the database

Wooohooooo!!!
I have a pdf with data on it!!!

Thank you very, very much, everyone, for all the help I’ve received on this. I’ll try to get the data printing in rows, tidy it up and post it on here for others who have similar issues in the future.
Thank you very much.

lol You should see some of my “in dev mode” files

I’ve learned to comment out until done instead of deleting

  • BUT -
    the files are a mess of “tried this - doesn’t work - maybe I can figure it out”
    “works somewhat but needs work”
    “tried this, doesn’t work, don’t bother trying it again”
    type of comments. Often more comments than actual code!

Glad it worked. Coffee works wonders.

I’ve learned to use xdebug.

With a little script like that you would have found the problem in under a minute using smart debugging.

Yes, my code started off with about 15 lines & was approaching about 200 with most commented out.
And, yes, brilliant stuff, coffee :smile:

I’ll have to look into xdebug. I’ve seen it around, but this project has kept me busy for the past 2 years. Now I’m at the stage of uploading and that’s where this problem arose - and I have a deadline to have it up & running by the end of the month. There hasn’t been time for studying anything else.

But I’ll definitely go & study up on xdebug :smile:

Thanks again. I really can’t express my gratitude, the relief is huge.

1 Like

Well I’m going to estimate you worked on this for about 2 hours. In that time you could have installed xdebug and learned a valuable skill in debugging which can be carried through to all your work. Effectively making you more productive and improving your development/problem solving skills ten-fold. That is all I’m saying. I just don’t understand how people can get through in life programming php without using smart debugging. It is SUCH a time saver and teaches you SO many valuable things that are continuous regardless of the code base/project. Not to mention you don’t risk accidentally pushing debug code to the live website. The first thing I do before starting a new project is stand-up a vm to host the project locally and hook-up xdebug with PHPStorm. I don’t start programming anything until all those things are accomplished. Even if it takes a day to figure out (which sometimes it may depending on how well the stars align) it is worth it in the long haul. Though recently puphpet.com and hooking-up xdebug with PHPStorm has been pretty easy (knock on wood).

Still weird that it worked on the development system but not on the hosted one.

I totally agree with you. I’m going to look into xdebug now - so I may be pushing a few more buttons on this subject. Do you have any advise as to where to start?

Yes, that still has me totally baffled. I have to get the more detailed forms to work now.

What do you use to write your PHP code? Do you use an IDE such as Netbeans, Sublime Text, or phpStorm? (you can say none of the above, or any of them above too – just want to try and find a more applicable article to what you are using)