Jump to content

In desperate need of help


Noskiw

Recommended Posts

cms_class.php

 

<?php

class modernCMS {
    
    var $host;
    var $username;
    var $password;
    var $db;
    
    function connect(){
        $con = mysql_connect($this->host, $this->username, $this->password) or die(mysql_error());
        mysql_select_db($this->db, $con) or die(mysql_error());
    } 
    
    function get_content(){
        $sql = "SELECT * FROM cms_content";
        $res = mysql_query($sql) or die(mysql_error());
        while($row = mysql_fetch_assoc($res)){
            echo "<h1>" . $row['title'] . "</h1>";
            echo "<p>" . $row['body'] . "</p>";
        }
    }
}

?>

 

index.php

 

<?php
include 'class/cms_class.php';

$obj = new modernCMS();

//Setup Our Connection Vars
$obj->host = 'localhost';
$obj->username = 'root';
$obj->password = '';
$obj->db = 'modernCMS';

//Connect To Our DB
$obj->connect();

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UFT-8" />
<title>My Modern CMS</title>
<link href="./style.css" rel="stylesheet" type="text/css" />

</head>

<body>
<div id="page-wrap">
        <?=$obj->get_content()?>
</div>
</body>
</html>

 

The problem that I seem to be having is when I load my page on "localhost", all at shows me is 'getcontent()?>' which is the function that I used in the divider. I know it probably seems like a really simple question to answer. But it's starting to get fairly annoying.

Link to comment
https://forums.phpfreaks.com/topic/200381-in-desperate-need-of-help/
Share on other sites

This means that PHP isn't being run on the code.  If you look at the emitted HTML, do you see <?php at the beginning by any chance?.

 

If yes, then there is something incorrect in your settings for PHP which to further debug we would need to know operating system and stuff for the configuration.

 

~juddster

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.