Error Class

Ask about a PHP problem here.
Post Reply
bowersbros
Posts: 534
Joined: Thu May 05, 2011 8:19 pm

Error Class

Post by bowersbros »

[syntax=php]<?php
class error {

public $body;
public $id;
public $dateSent = date('D, d M Y H:i:s O (T)');
public $page;
public $user;
public $headers;

public static function __construct($page = $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_POST'] . $_SERVER['URI'], $user = $_SERVER['username'], $headers = $_SERVER){
if(isset($page)){
$this->page = $page;
}
if(isset($user)){
$this->user = $user;
}
if(isset($headers)){
$this->headers = $headers;
}
}
public static function send($recipient) {

}
public static errorBody($body) {
$this->body = $body;

}
public static db(){
$dbuser = 'root';
$dbpass = 'PPZXZkKazTG8e4qf';
$dbh = new PDO('mysql:host=localhost;dbname=zuploadr',$dbuser,$dbpass);
$sth = $dbh->prepare('INSERT INTO `errors` (`errorId`, `body`, `page`,`user`,`headers`,`dateSent`) VALUES (?,?,?,?,?,?)');
$sth->bindParam(1, $this->id);
$sth->bindParam(2, $this->body);
$sth->bindParam(3, $this->page);
$sth->bindParam(4, $this->user);
$sth->bindParam(5, $this->headers);
$sth->bindParam(6, $this->dateSent);
$sth->execute();
}
public static function generateID($prefix = ''){
$this->id = uniqid($prefix);
}
public static function returnAddress($address) {
header('Location: ' . $address . '?errorId=' . $this->id);
}
}
?>[/syntax]

Anything I'm missing?
I don't like to brag, but I wasn't circumcised. I was circumnavigated. ;)

Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Error Class

Post by jacek »

Image
Post Reply