SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Threaded View

  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2013
    Posts
    35
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    PHP and MySQL: Novice to Ninja - Chapter Six totaljokes-function

    I'm not able to get this example to work. Here is my code for totalfilms-function.inc.php where titles = the name of a table in my db:
    PHP Code:
    <?php
    include_once $_SERVER['DOCUMENT_ROOT'] . '/includes/db.inc.php';
    function 
    totalFilms()
    {
        
    try {
    $result $GLOBALS['pdo']->query('SELECT COUNT(*) FROM titles');
      }
      catch (
    PDOException $e)
      {
        
    $error 'Database error counting films!';
        include 
    'error.html.php';
        exit();
    }
      
    $row $result->fetch();
      return 
    $row[0];
    }
    The only other file I have in the totalfilms directory is error.html.php. When I load up the directory this is what I get:
    Screen Shot 2013-11-02 at 10.39.09 AM.png
    It seems I need another file to display the result of the totalfilms function but I'm not sure how to write it.
    Attached Images Attached Images


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
  •