Noskiw Posted May 1, 2010 Share Posted May 1, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/200381-in-desperate-need-of-help/ Share on other sites More sharing options...
awjudd Posted May 1, 2010 Share Posted May 1, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/200381-in-desperate-need-of-help/#findComment-1051582 Share on other sites More sharing options...
Noskiw Posted May 1, 2010 Author Share Posted May 1, 2010 I'm using windows vista and XAMPP Quote Link to comment https://forums.phpfreaks.com/topic/200381-in-desperate-need-of-help/#findComment-1051586 Share on other sites More sharing options...
Mchl Posted May 1, 2010 Share Posted May 1, 2010 More likely short tags are disabled, so <?= shortcut doesn't work Quote Link to comment https://forums.phpfreaks.com/topic/200381-in-desperate-need-of-help/#findComment-1051591 Share on other sites More sharing options...
Noskiw Posted May 1, 2010 Author Share Posted May 1, 2010 Yes it was. Although, I did forget to include my $obj->connect(); The first time round I put the "<?php" tags instead of "<?=". Thank you anyway Quote Link to comment https://forums.phpfreaks.com/topic/200381-in-desperate-need-of-help/#findComment-1051610 Share on other sites More sharing options...
ignace Posted May 1, 2010 Share Posted May 1, 2010 Yes it was. Although, I did forget to include my $obj->connect(); The first time round I put the "<?php" tags instead of "<?=". Thank you anyway Never the less you should not rely on short tags. Quote Link to comment https://forums.phpfreaks.com/topic/200381-in-desperate-need-of-help/#findComment-1051631 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.