thedigicraft / Atom.CMS

Atom.CMS
56 stars 50 forks source link

Part 11 #60

Closed TTarrier closed 10 years ago

TTarrier commented 10 years ago

Upon creating the data.php file and changing the page setup to $page = data_page($dbc, $pageid); my page no longer displays any information at all.

thedigicraft commented 10 years ago

Could you post some of your code too please :-)

TTarrier commented 10 years ago

Sure

index.php

<?php include('config/setup.php');?>

<!DOCTYPE  HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <title><?php echo $page['title'].' | '.$site_title; ?></title>

    <meta  http-equiv="Content-Type" content="text/html;  charset=iso-8859-1">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <?php include ('config/css.php');?>

    <?php include ('config/js.php');?>

  </head>

  <body>

        <nav class="navbar navbar-default">
            <div class="container"> 
                <ul class="nav navbar-nav">
                    <li <?php if($pageid == 1) {echo 'class="active"';}?>><a href="?page=1">Home</a></li>
                    <li <?php if($pageid == 2) {echo 'class="active"';}?>><a href="?page=2">Specs</a></li>
                    <li <?php if($pageid == 3) {echo 'class="active"';}?>><a href="?page=3">Schedule</a></li>
                    <li <?php if($pageid == 4) {echo 'class="active"';}?>><a href="?page=4">Announcements</a></li>
                </ul>
              </div>

        </nav><!-- END Main Nav -->

        <div class="container">

            <h1><?php echo $page['header']; ?></h1>

            <p><?php echo $page['body']; ?></p>

        </div>

    <footer id="footer">

        <div class="container">
            <p>This is a Footer</p>
        </div>
    </footer><!-- End Footer -->

</body>
</html>

Setup.php:

<?php
//Setup File:

#Database Connection Here...
$dbc = mysqli_connect('******************','************','*************','***') OR die('Could not connect because: '.mysqli_connect_error());

# Functions:
include('function/data.php');

$site_title = 'Title';

if(isset($_GET['page'])) {

    $pageid = $_GET['page'];// Set $pageid to equal the value given in the URL

} else {

        $pageid = 1;// Set $pageid to equal to 1 or the Home Page

}

#Page Setup
    $data = data_page($dbc, $pageid);
?>

data.php:

<?php

function data_page($dbc, $id) {

    $q = "SELECT * FROM pages WHERE id = $id";
    $r = mysqli_query($dbc, $q);

    $data = mysqli_fetch_assoc($r);

    return $data;
}

 ?>
thedigicraft commented 10 years ago

Found it :-)

On this line...

#Page Setup
    $data = data_page($dbc, $pageid);

Change it to...

#Page Setup
    $page = data_page($dbc, $pageid);

Because here:

        <div class="container">

            <h1><?php echo $page['header']; ?></h1>

            <p><?php echo $page['body']; ?></p>

        </div>

You are referring to the $page array. Not $data

TTarrier commented 10 years ago

I made that change but I am still not seeing anything but a blank page.

TTarrier commented 10 years ago

I figured out the issue. I am running this on a linux server and did not have the /var/www file setup with the correct permissions so I could not access the files within. Thanks for the help.