Commit 6a5c20c0 authored by Julien1498's avatar Julien1498
Browse files

🐛 fix: close connection to database

parent ff2ba5cc
......@@ -69,6 +69,14 @@ function message($id, $text, $type){
</p>";
}
function username_available(){
$request = sqlrequest("eonweb","SELECT * FROM users WHERE user_name = ".$_COOKIE["user_name"]);
$result = mysqli_result($request,0,"user_name");
if(isset($result))
return true;
else return false;
}
// Connect to Database
function sqlrequest($database,$sql,$id=false,$prepare=false){
......@@ -127,14 +135,14 @@ function connexionDB($database){
}
function sql($database, $sql, $datas = false){
global $database_host;
global $database_username;
global $database_host;
global $database_username;
global $database_password;
$type = str_word_count($sql, 1);
$type = strtoupper($type[0]);
try {
$dbh = new PDO("mysql:host=$database_host;dbname=$database", $database_username, $database_password);
try {
$dbh = new PDO("mysql:host=$database_host;dbname=$database", $database_username, $database_password);
$stmt = $dbh->prepare($sql);
if(is_array($datas)){
......@@ -147,6 +155,9 @@ function sql($database, $sql, $datas = false){
$result = $stmt->fetch();
}
$dbh = null;
$stmt = null;
return $result;
} catch (PDOException $e) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment