Php Solutions chapter 13 issues

Discussion in 'PHP' started by needPhphelp, Apr 27, 2008.

  1. #1
    I'm working out of David Powers' book Php Solutions and really stuck on chapter 13 about creating a content management system. I keep getting the following when I try to view the journal entries page in my browser.

    Warning: include(../includes/conn_mysql.inc.php) [function.include]: failed to open stream: No such file or directory in /Applications/MAMP/htdocs/ch13/journal_list_mysql.php on line 2

    Warning: include() [function.include]: Failed opening '../includes/conn_mysql.inc.php' for inclusion (include_path='.:/Applications/MAMP/bin/php5/lib/php') in /Applications/MAMP/htdocs/ch13/journal_list_mysql.php on line 2

    Fatal error: Call to undefined function dbconnect() in /Applications/MAMP/htdocs/ch13/journal_list_mysql.php on line 4


    I have uploaded all of the relevant files and I just can't figure out what's wrong with line 2 and or 4 or anything before them.

    1 <?php
    2 include('../includes/conn_mysql.inc.php');
    3 // create database connection
    4 $conn = dbConnect('query');
    5 $sql = 'SELECT * FROM journal ORDER BY created DESC';
    6 $result = mysql_query($sql) or die(mysql_error());
    7 ?>


    Here is con_mysql.inc.php Am I suppose to change all of this stuff somehow?

    <?php
    function dbConnect($type) {
    if ($type == 'query') {
    $user = 'psquery';
    $pwd = 'fuji';
    }
    elseif ($type == 'admin') {
    $user = 'psadmin';
    $pwd = 'kyoto';
    }
    else {
    exit('Unrecognized connection type');
    }
    $conn = mysql_connect('localhost', $user, $pwd) or die ('Cannot connect to server');
    mysql_select_db('phpsolutions') or die ('Cannot open database');
    return $conn;
    }
    ?>

    Please help.
     
    needPhphelp, Apr 27, 2008 IP
  2. CPURules

    CPURules Peon

    Messages:
    67
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    change line 2 to this:

    include("/Applications/MAMP/htdocs/includes/conn_mysql.inc.php");
     
    CPURules, Apr 27, 2008 IP