Well, I'm not the one who made the script and I'm not that good at php, so .. :/ Would you be able to .. help me make this script work? Currently, it is
<?php
class mysql {
protected $_name;
protected $_hostname;
protected $_database;
protected $_username;
protected $_password;
protected $_handle = null;
public function __construct($name = null,$hostname = null,$database = null,$username = null,$password = null) {
$this->_name = $name;
$this->_hostname = $hostname;
$this->_database = $database;
$this->_username = $username;
$this->_password = $password;
}
public function __call($method, $args){
if (!$this->_handle)
$this->connect();
return call_user_func_array(array($this, $method), $args);
}
function connect() {
try {
$this->_handle = new PDO("mysql:host={$this->_hostname};dbname={$this->_database}",$this->_username,$this->_password);
$this->_handle->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$this->_handle->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
$this->error($e->getMessage());
return false;
}
}
function error($error) {
$file = fopen(PATH_ROOT."error_log.txt","a");
fwrite($file,date("H:i:s d/m/Y",time()).": ".$error." (".$_SERVER['REMOTE_ADDR'].")\r\n");
fclose($file);
}
protected function select($query,$array) {
if (!$this->_handle) return;
try {
$statement = $this->_handle->prepare($query);
$statement->execute($array);
return $statement->fetch();
} catch (PDOException $e) {
$this->error($e->getMessage());
return false;
}
}
protected function fetch($query,$array) {
if (!$this->_handle) return;
try {
$statement = $this->_handle->prepare($query);
$statement->execute($array);
return $statement->fetchAll();
} catch (PDOException $e) {
$this->error($e->getMessage());
return false;
}
}
protected function execute($query,$array) {
if (!$this->_handle) return;
try {
$statement = $this->_handle->prepare($query);
return $statement->execute($array);
} catch (PDOException $e) {
$this->error($e->getMessage());
return false;
}
}
protected function exec($query,$array) {
if (!$this->_handle) return;
try {
$statement = $this->_handle->prepare($query);
$statement->execute($array);
return $statement->rowCount();
} catch (PDOException $e) {
$this->error($e->getMessage());
return false;
}
}
}
$_handlerForum = new mysql("Forum","localhost","*********_fqipb2","*********_fqipb2","password");
$topics = $_handlerForum->fetch("SELECT `tid`,`title`,`last_post`,`title_seo`,`last_poster_name` FROM `topics` ORDER BY `last_post` DESC LIMIT 0,3;",array());
$content = "";
foreach($topics as $topic) {
$content .= "<a href='http://website.com/forum/index.php?/topic/".$topic['tid']."-".$topic['title_seo']."' target='_blank'>".$topic['title']."</a><br />
<small class='dim'>".$topic['last_poster_name']." - ".date("H:i F d, Y",$topic['last_post'])."</small><hr style='margin: 5px 0px;' />";
}
return $content;
return "Under Construction";
?>