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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.