// APP CONFIG
define("SERVER","localhost");
define("USER","root");
define("PASS","proU7ri9");
define("DB","syndicate");
// Set Site - USALAW.com *REQUIRED*
define("SITE_ID",1);
?>
// Simple MySQL Database class that I'll probably keep adding to
// -Miguel
class DB {
var $server, $user, $pass, $db;
function DB($server, $user, $pass, $db){
$this->server = $server;
$this->user = $user;
$this->pass = $pass;
$this->db = $db;
}
function query($sql){
$connection = mysql_connect($this->server, $this->user, $this->pass) or die("Could not connect to server: ". mysql_error());
mysql_select_db($this->db) or die("Could not associate with database: ". mysql_error());
$result = mysql_query($sql) or die('Query failed: ' . mysql_error());
$number_of_results = mysql_num_rows($result);
if($number_of_results == 0){
return false;
}elseif($number_of_results == 1){
$return_array[] = @mysql_fetch_array($result, MYSQL_ASSOC);
return $return_array;
}else{
while($row = @mysql_fetch_array($result, MYSQL_ASSOC)){
$return_array[] = $row;
}
return $return_array;
}
mysql_free_result($result);
mysql_close($connection);
}
function update($sql){
$connection = mysql_connect($this->server, $this->user, $this->pass) or die("Could not connect to server: ". mysql_error());
mysql_select_db($this->db) or die("Could not associate with database: ". mysql_error());
$result = mysql_query($sql) or die('Query failed: ' . mysql_error());
$row = @mysql_fetch_array($result, MYSQL_ASSOC);
mysql_close($connection);
}
function insert($sql){
$connection = mysql_connect($this->server, $this->user, $this->pass) or die("Could not connect to server: ". mysql_error());
mysql_select_db($this->db) or die("Could not associate with database: ". mysql_error());
$result = mysql_query($sql) or die('Query failed: ' . mysql_error());
$row = @mysql_fetch_array($result, MYSQL_ASSOC);
return mysql_insert_id($connection);
mysql_close($connection);
}
function delete($sql){
$connection = mysql_connect($this->server, $this->user, $this->pass) or die("Could not connect to server: ". mysql_error());
mysql_select_db($this->db) or die("Could not associate with database: ". mysql_error());
$result = mysql_query($sql) or die('Query failed: ' . mysql_error());
$row = @mysql_fetch_array($result, MYSQL_ASSOC);
mysql_close($connection);
}
}
?>
// Database Class
require_once "db.php";
class Comments{
var $id, $article_id, $user_id, $user_name, $comment, $time, $ip;
function Comments(){
}
function add_comment($article_id, $user_id, $user_name, $comment, $ip){
if(isset($article_id) && isset($user_id) && isset($ip)){
$db = new DB(SERVER, USER, PASS, DB);
$db->insert("insert into comments (comments_article_id, comments_user_id, comments_user_name, comments_comment, comments_time, comments_ip) values($article_id, $user_id, '$user_name', '".mysql_real_escape_string($comment)."', '".date("Y-m-d h:i:s",time())."', '$ip') ");
}
}
function remove_comment($comment_id){
}
function get_comments($article_id){
if(isset($article_id)){
$db = new DB(SERVER, USER, PASS, DB);
return $db->query("select * from comments where comments.comments_article_id = $article_id order by comments.comments_time desc");
}
}
function number_of_comments($article_id){
$total = 0;
$db = new DB(SERVER, USER, PASS, DB);
$row = $db->query("select comments_id from comments where comments.comments_article_id = $article_id ");
$size = count($row);
if($size > 0){
if(array_key_exists("comments_id", $row) && $size == 1){
$total = 1;
}else{
foreach($row as $value){
$total ++;
}
}
}
return $total;
}
}
?>
Fatal error: Class 'Comments' not found in C:\inetpub\wwwroot\law.powerfeed.com\includes\article.php on line 13