Raised This Month: $32 Target: $400
 8% 

Database tabels are not created


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kratoss1812
Senior Member
Join Date: May 2018
Location: Romānia
Old 12-28-2018 , 17:43   Database tabels are not created
Reply With Quote #1

Hello, does anyone knows what is wrong with this code? I don;'t know why but the tables are not created;

PHP Code:
Database g_MainDB;

public 
void OnPluginStart()
{
    
Database.Connect(OnConnect"new_store");
    
CreateTimer(60.0AddCredits);
    
    
RegConsoleCmd("sm_credits"Cmd_Credits);
}

public 
Action AddCredits(Handle pTimer)
{
    static 
int Player;

    for (
Player 1Player <= MaxClientsPlayer++)
    {
        
char Steam[32], sQuery[255];
        
__STEAM(PlayerSteam32);
        
Format(sQuery255"UPDATE new_store SET credits = credits + 1 WHERE steamid = '%s';"Steam);
        
g_MainDB.Query(Empty, sQuery);
    }
}

public 
void OnConnect(Database db, const char[] errorany data)
{
    if(
db == null)
        
SetFailState("Unable to connect to database: %s"error);
    
    
g_MainDB db;
    
    
char sQuery[256];
    
g_MainDB.Format(sQuerysizeof(sQuery), "CREATE TABLE IF NOT EXISTS `new_store` \
    ('name' varchar(128) NOT NULL, 'steamid' varchar(32), 'owned_items_id' varchar(360), 'credits' int(64))"
);
    
g_MainDB.Query(OnSQLConnectCallbacksQuery);
}

public 
void OnSQLConnectCallback(Database dbDBResultSet results, const char[] errorany data)
{
    if (
results == null)
    {
        
LogError("Query failure: %s"error);
        return;
    }
}

public 
void Empty(Handle pDbHandle pQuerychar[] Errorany Data){}

void __STEAM(int Idchar[] Outint Size)
{
    if (
IsFakeClient(Id))
        
FormatEx(OutSize"BOT@%N"Id);

    else
        
GetClientAuthId(IdAuthId_SteamID64OutSize);
}

public 
Action Cmd_Credits(int iClientint iArgs)
{
    
char Steam[32], sQuery[255];
    
__STEAM(iClientSteam32);
    
Format(sQuery255"SELECT credits FROM new_store WHERE steamid = '%s'"Steam);
    
g_MainDB.Query(ReplyCreditssQueryiClient);
}

public 
void ReplyCredits(Handle pDbHandle pQuerychar[] Errorany Data){
    
int iCredits SQL_FetchInt(pQuery0);
    
    
PrintToChat(Data"[ \x02STORE \x01] You have \x04%i \x01 Credits"iCredits);
}

public 
void OnClientPostAdminCheck(int iClient)
{
    
char Steam[32], sQuery[255], sName[32];
    
GetClientName(iClientsName32);
    
__STEAM(iClientSteam32);
    
Format(sQuery255"INSERT INTO new_store (name, steamid) VALUES ('%s', '%s');"sNameSteam);
    
g_MainDB.Query(ReplyCreditssQueryiClient);

__________________
kratoss1812 is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 12-28-2018 , 21:28   Re: Database tabels are not created
Reply With Quote #2

Any error msg in your log?
__________________
8guawong is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 12-29-2018 , 09:54   Re: Database tabels are not created
Reply With Quote #3

Remove the quotes around your column names.
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:45.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode