Forum Moderators: coopster
<?php
include("http://localhost/ladams/includes/constants.php");class MySQLDB {
var $connection; //The MySQL database connection
/* Class constructor */
function MySQLDB() {
/* Make connection to database */
$this->connection = mysql_connect('localhost', 'root', '') or die(mysql_error());
mysql_select_db('ladams') or die(mysql_error());
}
function getSiteNews ($x) {
$q = "SELECT * FROM site_news order by id desc limit 0,".$x;
$res = mysql_query($q);
return $res;
}
};
/* Create database connection */
$database = new MySQLDB;
global $database;
$news = $database->getSiteNews(1);
while ($row = mysql_fetch_row($news)) {
echo $row[0];
}
?>
However, if I take those last 5 lines of code out, and place them in my HTML file, with the database.php file as an include, I receive this error: Fatal error: Call to a member function getSiteNews() on a non-object in C:\wamp\www\ladams\index.html on line 56
What am I missing here? Thanks!