Page 151 - PHP Novice to Ninja

Always in PHP Novice to Ninja book, I have a problem yet.
Page 151, I updated the code in my jokes.html.php file, but when I go to view the result in the browser, I received these errors:

Warning: Illegal string offset ‘text’ in /Applications/MAMP/htdocs/joinjoke/jokes.html.php on line 14
I (by
Warning: Illegal string offset ‘name’ in /Applications/MAMP/htdocs/joinjoke/jokes.html.php on line 20
I)

Why?
Thank you

Can you post your code?

    <!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>List of Jokes</title>
  </head>
  <body>
    <p><a href="?addjoke">Add your own joke</a></p>
    <p>Here are all the jokes in the database:</p>
    <?php foreach ($jokes as $joke): ?>
      <form action="?deletejoke" method="post">
        <blockquote>
          <p>
            <?php echo htmlspecialchars($joke['text'], ENT_QUOTES, 'UTF-8'); ?>
            <input type="hidden" name="id" value="<?php echo $joke['id']; ?>">
            <input type="submit" value="Delete">
            (by <a href="mailto:<?php
                echo htmlspecialchars($joke['email'], ENT_QUOTES,
                    'UTF-8'); ?>"><?php
                echo htmlspecialchars($joke['name'], ENT_QUOTES,
                    'UTF-8'); ?></a>)
          </p>
        </blockquote>
      </form>
    <?php endforeach; ?>
  </body>
</html>

It doesn’t look like you’ve followed the advice given in your earlier topic

Can you also post your chapter5/jokes/index.php page?

Sorry to all, I have reload a previous version of my index.php file.

Thank you for your quickly answers.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.