SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Member
    Join Date
    Mar 2005
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Retrieve jokes in Kevin Yank's database (was "Help!")

    I am new to PHP and am working through the examples in the Build your own Database Driven Website using PHP & MySQL. PHP works fine and have added a couple of more jokes to the sample database. When I come to chapter 4 to retrieve the jokes in the database (listing 4.2), there is just a blank page. Any ideas ? Thanks

  2. #2
    SitePoint Zealot Med's Avatar
    Join Date
    Oct 2002
    Location
    The Netherlands
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just arrived in chapter 5, my guess is that you forgot to insert a ' somewhere. I forgot it once, and all i saw was a blank page. I quickly learned not to make that mistake again.

    if you use an app with code-coloring it should be easy to spot the mistake.

  3. #3
    SitePoint Member
    Join Date
    Mar 2005
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Med
    I just arrived in chapter 5, my guess is that you forgot to insert a ' somewhere. I forgot it once, and all i saw was a blank page. I quickly learned not to make that mistake again.

    if you use an app with code-coloring it should be easy to spot the mistake.
    I'm not sure what you mean by the ' and where would it go ?

    Thanks for your help by the way!

  4. #4
    SitePoint Zealot Med's Avatar
    Join Date
    Oct 2002
    Location
    The Netherlands
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well there are a few to be found in the code. So if you would post the code you have now, it would help to see where it should go. Or to see if it is another problem.

    Or download the code-archive. If you use bbedit you can compare the original file and yours for differences.

  5. #5
    SitePoint Member
    Join Date
    Mar 2005
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is the code. It's the download from the book with my own password.
    Thanks.

    <!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">
    <head>
    <title>Our List of Jokes</title>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    </head>
    <body>
    <?php

    // Connect to the database server
    $dbcnx = @mysql_connect('localhost', 'root', 'mcfcok');
    if (!$dbcnx) {
    exit('<p>Unable to connect to the ' .
    'database server at this time.</p>');
    }

    // Select the jokes database
    if (!@mysql_select_db('ijdb')) {
    exit('<p>Unable to locate the joke ' .
    'database at this time.</p>');
    }

    ?>
    <p>Here are all the jokes in our database/p>
    <blockquote>
    <?php

    // Request the text of all the jokes
    $result = @mysql_query('SELECT joketext FROM joke');
    if (!$result) {
    exit('<p>Error performing query: ' . mysql_error() . '</p>');
    }

    // Display the text of each joke in a paragraph
    while ($row = mysql_fetch_array($result)) {
    echo '<p>' . $row['joketext'] . '</p>';
    }

    ?>
    </blockquote>
    </body>
    </html>

  6. #6
    SitePoint Zealot Med's Avatar
    Join Date
    Oct 2002
    Location
    The Netherlands
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can't find any problems in it. It probably has to do with your server configuration.

    One suggestion. Don't post your password! Someone just needs to get your ip and they're in... So i suggest you change the password now.

  7. #7
    SitePoint Member
    Join Date
    Mar 2005
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok cheers !!!

  8. #8
    SitePoint Member
    Join Date
    Mar 2005
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes I was thinking that. When I start MySQL services in services.msc from the run command it comes up "Could not start the MySql service on Local Computer Error 1067. The process terminated unexpectedly."
    Do I even need to be running from it here as I have been running it from the

    command promt F:\mysql\bin>mysql-nt --install.

    It then comes up "The service already exists!"

    Any ideas ! Thanks.

  9. #9
    SitePoint Zealot Med's Avatar
    Join Date
    Oct 2002
    Location
    The Netherlands
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry mate, i work on a Mac, so i can't help you on that one. But the installation instructions are in the book. That's the best advice i can give you now.


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
  •