我编写了一个从数据库用户获取数据的函数,但我收到此错误消息:
24-Nov-2018 15:06:58 UTC] PHP注意:MySQL错误您的SQL语法有错误;检查与您的MySQL服务器版本相对应的手册以获取正确的语法,以在第1行的''附近使用
SELECT积分,0个day_winnings,lifetime_winnings来自5fa_users,其中id =;
在第95行的/home3/jcodedes/public_html/slots/db.php中的[24-Nov-2018 15:06:59 UTC] PHP注意:MySQL错误您的SQL语法错误;检查与您的MySQL服务器版本相对应的手册以获取正确的语法,以在第1行的''附近使用
SELECT积分,0个day_winnings,lifetime_winnings来自5fa_users,其中id =;
在第95行的/home3/jcodedes/public_html/slots/db.php中
这是代码:
<?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);
}
}
我能做些什么来解决这个问题?
答案 0 :(得分:1)
您确定word_positions
{0: 'zero',
1: 'one',
2: 'two',
3: 'three',
4: 'four',
5: 'five',
6: 'six',
7: 'seven',
8: 'eight',
9: 'nine',
10: 'ten'}
返回ID吗?
您会在错误消息中注意到,执行的SQL是:
DB::DQ($ID)
ID为空。 Wich可能表示该函数未返回ID或该函数未接收ID。