It works on my localhost but not on the server. Does this mean the database is not connecting at all or do I have something wrong in the statements?
$submission = $_POST['submit'];
$decode = json_decode($submission, true);
try {
$pdo = new PDO('mysql:localhost;dbname=database', 'username', 'password');
} catch(PDOException $e){
echo 'PDO Exception: '.$e->getMessage();
die();
}
class QueryBuilder {
protected $pdo;
public function __construct($pdo){
$this->pdo = $pdo;
}
public function insert($parameters){
$sql = "insert into tableName ('entry', 'author', 'email', 'sign', 'month') values (:entry, :author, :email, :sign, :month)";
$statement = $this->pdo->prepare($sql);
try {
$statement->execute($parameters);
} catch (Exception $e) {
die($e->getMessage());
}
}
}
$query = new QueryBuilder($pdo);
$query->insert($decode);
I even tried a table clearing statement and it also does nothing...
public function clear(){
try {
$statement = $this->pdo->prepare("truncate table submissions");
$statement->execute();
} catch (Exception $e) {
die($e->getMessage());
}
}
$query->clear();