A better way to make a connection to the database

This commit is contained in:
pikami
2016-06-16 15:33:16 +00:00
parent 4c1f18c593
commit e9ccb5c919
11 changed files with 48 additions and 32 deletions

View File

@@ -6,7 +6,8 @@
$uid = $_GET["page"];
echo '<script type="text/javascript" src="js/SyntaxHighlighter/shCore.js"></script>';
//
include "config/config.php";
include_once "config/config.php";
$conn = GetConnectionToDB();
$stmt = $conn->query('SELECT highlight FROM pastes WHERE uid="'.$uid.'"');
if($result = $stmt->fetch(PDO::FETCH_ASSOC)){
$conn = null;

View File

@@ -1,6 +1,7 @@
<?php
function GetUsersIDBySession($sid,$skey){
include "config/config.php";
include_once "config/config.php";
$conn = GetConnectionToDB();
$stmt = $conn->prepare("SELECT uid FROM sessions WHERE id=:sid AND skey=:skey");
$stmt->bindParam(':skey', $skey);
$stmt->bindParam(':sid', $sid);
@@ -14,7 +15,8 @@ function GetUsersIDBySession($sid,$skey){
}
}
function LogOutUserBySession($sid,$skey){
include "config/config.php";
include_once "config/config.php";
$conn = GetConnectionToDB();
$stmt = $conn->prepare("DELETE FROM sessions WHERE id=:sid AND skey=:skey");
$stmt->bindParam(':skey', $skey);
$stmt->bindParam(':sid', $sid);
@@ -27,7 +29,8 @@ function UnsetBrowserCookies(){
setcookie("pp_skey", '', time() - 3600);
}
function GetUserByID($id){
include "config/config.php";
include_once "config/config.php";
$conn = GetConnectionToDB();
$stmt = $conn->prepare("SELECT * FROM users WHERE id=:id");
$stmt->bindParam(':id', $id);
$stmt->execute();