I do a little homework in which we do a very rudimentary CMS. We must fill out a form containing the name, body, permalink. Then the CMS takes the permalink and adds it to the main navigation bar. When this permalink is clicked on the navigation bar, the title, content, date-stop and date-strain will be displayed. This stuff works for me, only the problem is that when I click on the nav link, I have these errors:
Note. The DB_HOST constant is already defined in C: \ Program Files \ xampp \ htdocs \ php \ assign_6 \ config.php on line 2
Note. The DB_USER constant is already defined in C: \ Program Files \ xampp \ htdocs \ php \ assign_6 \ config.php on line 3
Note. The DB_PASS constant is already defined in C: \ Program Files \ xampp \ htdocs \ php \ assign_6 \ config.php on line 4
Note. The DB_NAME constant is already defined in C: \ Program Files \ xampp \ htdocs \ php \ assign_6 \ config.php on line 5
I have a config.php file that I use to establish a database connection:
<?php define('DB_HOST','******'); define('DB_USER','******'); define('DB_PASS','******'); define('DB_NAME','******'); $cms_db = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME); if(!$cms_db){ echo"Could not connect: ".mysql_error(); } ?>
Here is the code from my file that calls the config.php file that causes the error:
<?php require('config.php'); $perm = $_GET['p']; $query = "SELECT * FROM cms WHERE permalink = '$perm'"; $result = $cms_db->query($query); $row = $result->fetch_assoc(); $page_title = $perm; require('header.php'); ?> <h1><?=$row['title'];?></h1> <hr/><br/> <p class="para"><?=$row['content']?></p> <?php require('footer.php');?>
A small amount of simple code, but what is the problem? This is not a fatal mistake, but man, it is annoying.
Phill cookie
source share