Hi guys, ok I'm going through this book called "Learning PHP Data Objects". Just saying so there's a reference. Anyway I'm getting the following error when I upload the code below. The page is saved as books.xm.php. Can anyone help me?

I know it makes the code easier to read with empty lines, but try removing the first couple.

heretolearn
—
2013-12-04T05:12:04Z —
#3

The page outputs

This page contains the following errors:

error on line 2 at column 1: Extra content at the end of the document

Below is a rendering of the page up to the first error.

droopsnoot
—
2013-12-04T12:38:40Z —
#4

Forgive my posting as I'm learning php myself. But in that last loop, you have a lot of constructs that are basically <?=htmlspecialchars($var)?> - is that an alternate method of embedding php within html, or a lot of typos? I'd have done it as

<?php echo htmlspecialchars($var); ?>

is that just a longer way of doing the same thing or related to the PDO library being used?

Mittineague
—
2013-12-04T18:55:00Z —
#5

Those are "short tags". They work OK as long as PHP is configured with them enabled. I've never used them as having "echo" doesn't add that much more verbosity and the code will still work if short tags are not enabled.

Maybe looking at view-source would show something helpful?

And instead of the sequential "echos" maybe string concatenation with a single echo would work?eg.instead ofecho "<tag>";try$xml_string .= "<tag>";......echo $xml_string;

droopsnoot
—
2013-12-05T11:34:17Z —
#6

Mittineague said:

Those are "short tags". They work OK as long as PHP is configured with them enabled. I've never used them as having "echo" doesn't add that much more verbosity and the code will still work if short tags are not enabled.

Ah, thanks for that. I did a quick search but it confused Google. Back to topic everyone.