Thread: [Solved] Retrieve data from sql
View Single Post
N3v3rM1nd
Member
Join Date: Apr 2021
Old 05-04-2024 , 08:02   Re: Retrieve data from sql
Reply With Quote #8

This is the error
PHP Code:
Load Query failed. [1near "("syntax error 
I've searched for what might have caused the error and tried everything that could be tried, but in vain.

This is what I currently have in the script:

PHP Code:
new szData[1]; szData[0] = iPlayer
new szTemp[512]
...

else if(
equali(cMessage"/rank") || equali(cMessage"rank"))
{
format(szTempcharsmax(szTemp),
"
WITH rankedPlayers AS (
SELECT
steamid,
name,
score,
points,
infections,
kills,
deaths,
RANK() OVER (ORDER BY score DESC) AS rank,
(SELECT COUNT(*) FROM %s) AS total_players
FROM
%s
)
SELECT
steamid,
name,
score,
rank,
total_players,
points,
infections,
kills,
deaths
FROM
rankedPlayers
WHERE
steamid = '%s';
"
,
TABELTABELg_cSteam[iPlayer]
);
SQL_ThreadQuery(g_SqlTuple"ZP_RANK"szTempszData1)
return 

PHP Code:
public ZP_RANK(FailStateHandle:QueryError[], ErrcodeData[], DataSize)
{
if(
FailState == TQUERY_CONNECT_FAILED)
log_amx("Load - Could not connect to SQL database. [%d] %s"ErrcodeError)
else if(
FailState == TQUERY_QUERY_FAILED)
log_amx("Load Query failed. [%d] %s"ErrcodeError)

new 
idid Data[0]
if(!
is_user_connected(id))
    return

if(
SQL_NumResults(Query))
{
    new 
score SQL_ReadResult(Query2)
    new 
rank SQL_ReadResult(Query3)
    new 
total SQL_ReadResult(Query4)
    new 
points SQL_ReadResult(Query5)
    new 
infections SQL_ReadResult(Query6)
    new 
kills SQL_ReadResult(Query7)
    new 
deaths SQL_ReadResult(Query8)

    
PrintToChat(id"^x04[ZP] ^x01 Your rank is %i/%i with a score of %i >> %i kills %i deaths, %i infections and %i points.", \
        
ranktotalscorekillsdeathsinfectionspoints)
}
else 
PrintToChat(id"^x04[ZP] You don't have any rank !")

Its saying "You don't have any rank" for everyone

Last edited by N3v3rM1nd; 05-04-2024 at 08:06.
N3v3rM1nd is offline