For some reason this code doesn't want to work. It is supposed to figure out if the user has enough credits to put into a giveaway. And before you ask, yes I have defined "credits" just in a different file (the one in which the user specifies how many credits they want to bet)
<?php
session_start();
$servername = "localhost";
$username = "root";
$password = "htq6m2";
$dbname = "transactions";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$query = "SELECT sum(points) AS points FROM transactions WHERE username = '".mysqli_real_escape_string($conn,$_SESSION['userid'])."'";
$result = mysqli_query($conn, $query);
$row = mysqli_fetch_assoc($result);
if ($_GET["credits"] > $row) {
echo("You don't have enough credits for that bet!");
} else {
echo("Nice you've got enough credits!")
}
?>
Aucun commentaire:
Enregistrer un commentaire