Jump to content
Larry Ullman's Book Forums

joykwame

Members
  • Posts

    8
  • Joined

  • Last visited

Posts posted by joykwame

  1. This is what I got "Document root: C:/xampp/htdocs" and have inserted it.

     

    define ('BASE_URL', 'Document root: C:/xampp/htdocs');

    define ('BASE_URL', 'localhost/');

    define ('MYSQL', BASE_URI . 'mysql_inc.php');

     

    and on index.php, I change this "require($_SERVER['DOCUMENT_ROOT'] . '\mysql.inc.php');"

    back to "require (MYSQL);" but this is what I got:

     

     

    Fatal error: require(): Failed opening required 'BASE_URImysql_inc.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\index.php on line 4

     

    This is my second book after the recommended php for the web book but I don't remember seeing

    anything like this.

  2. Hi Rob,

     

    Please find the code below.

     

    index.php

     

     

    <?php

    require ('includes/config.inc.php');

    include ('includes/header.html');

    require (MYSQL);

    ?>

    <h3>Welcome</h3>

    <p>Welcome to Knowledge is Power, a site dedicated to keeping you up to date on the web security and programming information you need to know. Blah, blah, blah.</p>

     

    <?php

    include ('includes/footer.html');

    ?>

  3. Hi Forum Members,

     

    I've been struggling for some time on the above topic. I've tried everything I've read but

    still can't get it to work in xampp. Can someone help me please.

     

    Directories structure

    C:xampp\htdocs\

     

     

     

    The error I'm getting is as follows:

     

    Fatal error: require(): Failed opening required 'C:\xampp\htdocs\mysql_inc.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\index.php on line

     

     

    And my code is as follows:

     

    config.inc.php

     

    //Base url constants declaration

    define ('BASE_URI', 'C:\\xampp\htdocs\\');

    define ('BASE_URL', 'localhost/');

    define ('MYSQL', BASE_URI . 'mysql_inc.php');

     

    //starting a session for the logins

    session_start();

     

    mysql.inc.php

     

    <?php

    //define constants for the db connection

    DEFINE ('DB_HOST', 'localhost');

    DEFINE ('DB_USER', 'AMPONSAH');

    DEFINE ('DB_PASSORD', 'password');

    DEFINE ('DB_NAME', 'ecommerce1');

     

    //connect to mysql

    $dbc = mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);

    //----------------------------- MYSQL CONNECTION ------------------------------------------------------

    //establish character set

    mysqli_set_charset($dbc, 'utf8');

×
×
  • Create New...