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
Warning: Illegal string offset ‘name’ in /Applications/MAMP/htdocs/joinjoke/jokes.html.php on line 20
<title>List of Jokes</title>
<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">
<?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,
echo htmlspecialchars($joke['name'], ENT_QUOTES,
<?php endforeach; ?>
It doesn’t look like you’ve followed the advice given in your earlier topic
I am studying on Novice to Ninja 5th Edition, in particular the four Chapter page 136.
I can to add and delete jokes fine, but when delete the last one, I have these errors:
Notice: Undefined variable: jokes in /Applications/MAMP/htdocs/deletejoke/jokes.html.php on line 10
Warning: Invalid argument supplied for foreach() in /Applications/MAMP/htdocs/deletejoke/jokes.html.php on line 10
I am using the source code download from website.
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.