SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member
    Join Date
    Jul 2011
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Database driven website by Kevin Yank

    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.

    Code:
    Fatal error: Call to undefined function bbcodeout() in C:\xampp\htdocs\test\jokes\jokes.html.php on line 18
    I also get the same error when searching at http://localhost/test/admin/jokes/

    Here is the code for jokes.html.php from chapter 8
    Code:
    <?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.

    Help please?

    I'm running XAMPP 2.5

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,182
    Mentioned
    191 Post(s)
    Tagged
    2 Thread(s)
    Hi dcd018,

    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
    PHP Code:
    <?php include_once $_SERVER['DOCUMENT_ROOT'] .
            
    '/includes/helpers.inc.php'?>
    in the right place with the right spelling.

    The helpers.inc.php file used in chapter 7 doesn't have a
    function bbcode2html($text)

    Did you remember to upgrade it with the one for chapter 8?

  3. #3
    SitePoint Member
    Join Date
    Jul 2011
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Mittineague, helpers.inc.php is updated and it's in includes folder

    Code:
    function bbcodeout($text)
    {
    	echo bbcode2html($text);
    }
    So <?php bbcodeout($joke['text']); ?> in jokes.html.php should call function bbcodeout($text) from helpers.inc.php, or am I missing something?

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,182
    Mentioned
    191 Post(s)
    Tagged
    2 Thread(s)
    Yes, it should be.

    Maybe its a permissions issue?

    What happens if you type the path to it in your browser address bar?

  5. #5
    SitePoint Member
    Join Date
    Jul 2011
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's what I get when I go to http://localhost/test/jokes/jokes.html.php

    Code:
    Add your own joke
    
    Here are all the jokes in the database:
    
    Notice: Undefined variable: jokes in C:\xampp\htdocs\test\jokes\jokes.html.php on line 14
    
    Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\test\jokes\jokes.html.php on line 14
    I'm at a loss ... uninstalling/reinstalling XAMPP see if that does it.

  6. #6
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by dcd018 View Post
    ]I'm at a loss ... uninstalling/reinstalling XAMPP see if that does it.

    Its a coding thing rather than a XAMPP thing so dont uninstall it!
    What value do you get if you echo the path?
    PHP Code:
    echo $_SERVER['DOCUMENT_ROOT'] . '/includes/helpers.inc.php'
    Check that the DOCUMENT_ROOT and paths are right.
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  7. #7
    SitePoint Member
    Join Date
    Jul 2011
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

    Thanks!

  8. #8
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Glad you got it sorted
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •