Jump to content

EimantasFHQ

New Members
  • Posts

    5
  • Joined

  • Last visited

EimantasFHQ's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. 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"; ?>
  2. Thank you! Added that line of code, so now it doesn't show any error. But .. blank page. What could be the problem? SEO?
  3. Hey! So, I don't know if this is the current section, couldn't really decide on what section/board to post it, so .. I've got a code that I got from a friend of mine (it was a gaming website (a game server), but he shut it down, I asked for some scripts, he sent me the whole site ..). I got all other scripts correctly, but I do not know how to get this Last Forum Posts to work (IP.Board). I've got the SEO set up as it should and everything, doesn't work. When I use this <?php $_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"; ?> I get this error Fatal error: Class 'mysql' not found in /home/***/***/***/public_html/extra/forum.php on line 2 Thought that the problem was "new mysql" (on line 2), so I put in mysql_connect, still get an error. Can anyone help?
×
×
  • 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.