my index.php
<?PHP
include('db.class.php');
$bdd = new db();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<title>Voting System</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css" type="text/css">
<script type="text/javascript" src="jquery/jquery-1.10.1.min.js"></script>
<style>
.arrow_up a { display: block; background: url("voteup.png") no-repeat; width: 26px; height: 13px }
.arrow_up a:hover { background-position: 0 -13px; width: 26px; height: 13px }
.arrow_up_voted { display: block; background: url("votedown.png") no-repeat; width: 26px; height: 13px }
.arrow_down a { display: block; background: url("votedown.png") no-repeat; width: 26px; height: 13px }
.arrow_down a:hover { background-position: 0 -13px; width: 26px; height: 13px }
.arrow_down_voted { display: block; background: url("votedown.png") no-repeat; width: 26px; height: 13px }
.number { font-size: 18px; color: #818185; padding: 7px 0 7px 0; }
.voting_table { margin-right: 20px; }
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-12">
<?php
$articles = $bdd->getAll('SELECT * FROM tc_tuto_voting_system'); // Select the article list
foreach($articles as $article) { // Loop - for each article...
$cookie_name = 'tcVotingSystem'.$article['id']; // Set up the cookie name
echo '<div class="panel panel-default">';
echo '<div class="panel-heading">Article '.$article['id'].'</div>'; // Article name + id
echo '<div class="panel-body">';
echo '<table class="voting_table pull-left">';
echo '<tr>';
echo '<td align="center">';
if( isset($_COOKIE[$cookie_name]) ) { // If the cookie exists (means if we have already voted for this article)
echo '<div class="arrow_up_voted"></div>'; // We display a simple "arrow up", not clickable
} else {
?>
<!-- else we display the clickable "arrow up". We call a function and pass the arguments article ID and the value +1 -->
<div class="arrow_up" id="arrow_up<?php echo $article['id']; ?>"><a href="#" id="arrowUp" onclick="vote(<?php echo $article['id']; ?>, '+1'); return false;"></a></div>
<?php
}
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td align="center">';
echo '<div class="number" id="number'.$article['id'].'">'.$article['total'].'</div>'; // We display the number of click
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td align="center">';
if( isset($_COOKIE[$cookie_name]) ) { // Same for the "arrow down": if the cookie exists (means if we have already voted for this article)
echo '<div class="arrow_down_voted"></div>'; // We display a simple "arrow down", not clickable
} else {
?>
<!-- else we display the clickable "arrow down". We call a function and pass the arguments article ID and the value -1 -->
<div class="arrow_down" id="arrow_down<?php echo $article['id']; ?>"><a href="#" id="arrowDown" onclick="vote(<?php echo $article['id']; ?>, '-1'); return false;"></a></div>
<?php
}
echo '</td>';
echo '</tr>';
echo '</table>';
echo '<span id="message'.$article['id'].'"></span>'; // Display message "Thank you for voting"
echo 'Up branch to easily missed by do. Admiration considered acceptance too led one melancholy expression. Are will took form the nor true. Winding enjoyed minuter her letters evident use eat colonel. He attacks observe mr cottage inquiry am examine gravity. Are dear but near left was. Year kept on over so as this of. She steepest doubtful betrayed formerly him. Active one called uneasy our seeing see cousin tastes its. Ye am it formed indeed agreed relied piqued.';
echo '</div>';
echo '</div>';
}
?>
</div>
</div>
</div>
<script type="text/javascript" src="tuto-voting-system.js"></script>
</body>
</html>
my db.class.php
<?php
class db {
private $conn;
private $host;
private $user;
private $password;
private $baseName;
private $port;
private $Debug;
function __construct($params=array()) {
$this->conn = false;
$this->host = 'localhost'; //hostname
$this->user = 'root'; //username
$this->password = ''; //password
$this->baseName = 'db'; //name of your database
$this->debug = true;
$this->connect();
}
function __destruct() {
$this->disconnect();
}
function connect() {
if (!$this->conn) {
try {
$this->conn = new PDO('mysql:host='.$this->host.';dbname='.$this->baseName.'', $this->user, $this->password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
}
catch (Exception $e) {
die('Erreur : ' . $e->getMessage());
}
if (!$this->conn) {
$this->status_fatal = true;
echo 'Connection BDD failed';
die();
}
else {
$this->status_fatal = false;
}
}
return $this->conn;
}
function disconnect() {
if ($this->conn) {
$this->conn = null;
}
}
function getOne($query) {
$result = $this->conn->prepare($query);
$ret = $result->execute();
if (!$ret) {
echo 'PDO::errorInfo():';
echo '<br />';
echo 'error SQL: '.$query;
die();
}
$result->setFetchMode(PDO::FETCH_ASSOC);
$reponse = $result->fetch();
return $reponse;
}
function getAll($query) {
$result = $this->conn->prepare($query);
$ret = $result->execute();
if (!$ret) {
echo 'PDO::errorInfo():';
echo '<br />';
echo 'error SQL: '.$query;
die();
}
$result->setFetchMode(PDO::FETCH_ASSOC);
$reponse = $result->fetchAll();
return $reponse;
}
function execute($query) {
if (!$response = $this->conn->exec($query)) {
echo 'PDO::errorInfo():';
echo '<br />';
echo 'error SQL: '.$query;
die();
}
return $response;
}
}
when I upload it on server. nothing shows up.
please tell me how do i fix this