This is my first post here so apologies if the format is kind of messed up, I’m reading Build your own database driven website using PHP and MySQL. Until chapter 8, I managed to get all of the exercises to work with XAMPP on Win7 using the exact source code from the reference section.
When I put admin, includes and jokes folder into test folder located in c:/xampp/htdocs, and go to http://localhost/test/jokes, I get this where the list of jokes should be.
Fatal error: Call to undefined function bbcodeout() in C:\\xampp\\htdocs\ est\\jokes\\jokes.html.php on line 18
Here is the code for jokes.html.php from chapter 8
<?php include_once $_SERVER['DOCUMENT_ROOT'] .
'/includes/helpers.inc.php'; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>List of Jokes</title>
<meta http-equiv="content-type"
content="text/html; charset=utf-8"/>
</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 bbcodeout($joke['text']); ?>
<input type="hidden" name="id" value="<?php
echo $joke['id']; ?>"/>
<input type="submit" value="Delete"/>
</p>
</blockquote>
</form>
<?php endforeach; ?>
</body>
</html>
I haven’t a clue as to what I did wrong since every exercise has worked up to this point, obviously it has something to do with bbcodeout but I couldn’t find any reference to this problem online.
Well. if you are using the files from the code archive, then I hope it isn’t because the code is buggy! Checking the book’s errata page for known errors I don’t see anything about it.
So what is it? My first guess is the path and or file name is off. But, if things were working in chapter 7, then you must have had
Add your own joke
Here are all the jokes in the database:
Notice: Undefined variable: jokes in C:\\xampp\\htdocs\ est\\jokes\\jokes.html.php on line 14
Warning: Invalid argument supplied for foreach() in C:\\xampp\\htdocs\ est\\jokes\\jokes.html.php on line 14
I’m at a loss :mad: … uninstalling/reinstalling XAMPP see if that does it.
That was it! I had an includes folder in root from chapter 7 and just figured the includes folder in test folder from chapter 8 was being used. I just forgot to switch out the root folders for includes.