I wrote a function to get data from db users but i recive this error message:
24-Nov-2018 15:06:58 UTC] PHP Notice: MySQL error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
SELECT credits, 0 AS day_winnings, lifetime_winnings FROM 5fa_users WHERE id = ;
in /home3/jcodedes/public_html/slots/db.php on line 95 [24-Nov-2018 15:06:59 UTC] PHP Notice: MySQL error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
SELECT credits, 0 AS day_winnings, lifetime_winnings FROM 5fa_users WHERE id = ;
in /home3/jcodedes/public_html/slots/db.php on line 95
This is the code:
<?php
class Users {
// This function gets called *a lot*, so it must be very quick to run. Cache stuff if necessary.
public static function LoggedUserID() {
return isset($_SESSION['ID']) ? $_SESSION['ID'] : null;
}
// Must return credits, day_winnings and lifetine_winnings
// Day_winnings may be implemented in multiple different ways. The server doesn't implement them as-is
public static function GetUserData($ID) {
return DB::SingleRow("SELECT credits, 0 AS day_winnings, lifetime_winnings FROM 5fa_users WHERE id = " . DB::DQ($ID) . ";");
}
public static function IncrementSlotMachineSpins($ID) {
DB::Execute("UPDATE 5fa_users SET spins = spins + 1 WHERE id = " . DB::DQ($ID) . ";");
}
public static function DeductCredits($ID, $bet) {
DB::Execute("UPDATE 5fa_users SET credits = credits - " . DB::DQ($bet) . " WHERE id = " . DB::DQ($ID) . ";");
// If you have any sort of audit for your user's credits, you want to log into that
}
public static function IncreaseCredits($ID, $payout) {
DB::Execute("UPDATE 5fa_users SET credits = credits + " . DB::DQ($payout) . " WHERE id = " . DB::DQ($ID) . ";");
// If you have any sort of audit for your user's credits, you want to log into that
}
public static function IncreaseWinnings($ID, $payout) {
DB::Execute("UPDATE 5fa_users SET lifetime_winnings = lifetime_winnings + " . DB::DQ($payout) . " WHERE id = " . DB::DQ($ID) . ";");
// If you have any sort of audit for your user's credits, you want to log into that
// If you keep track of day_winnings, you probably want to update them here too
}
public static function HasEnoughCredits($ID, $bet){
$userData = self::GetUserData($ID);
return ($userData['credits'] >= $bet);
}
}
What i can do to solve it?