Raised This Month: $ Target: $400
 0% 

Problem for query sql


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mickael002
Senior Member
Join Date: Jul 2010
Old 02-21-2013 , 15:55   Problem for query sql
Reply With Quote #1

Hello,

(Sorry for my bad english, i'm french)

I have a problem for get a info from database.

I have this 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 ':1:21011029' at line 1

Script :
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <morecolors>

#define PLUGIN_VERSION "1.0"
#define MAX_LINE_WIDTH 60
#define MAX_AUTHID_LENGTH 50


new Handle:db;
new 
DEBUG 1

new String:steamIdSave[64][255];



public 
Plugin:myinfo =
{
    
name "",
    
author "Mickael",
    
description "Regenere le mot de passe de la boutique vip",
    
version PLUGIN_VERSION,
    
url "www.team-ninja.fr"
}

public 
OnPluginStart()
{
    
// Loading plugin translations.
    
LoadTranslations("cadeau_noel.phrases");
    
    
RegConsoleCmd("sm_getinfosql"Command_getinfosql);
    
    
SQL_TConnect(LoadMySQLBase"default");
}


public 
Command_getinfosql(clientargs)
{
    
get_data_forcmd(client);
}

public 
get_data_forcmd(client){        
        if (
db != INVALID_HANDLE)
        {        
            
decl String:steamId[64];
            
GetClientAuthString(clientsteamIdsizeof(steamId));
            
steamIdSave[client] = steamId;
            
            
decl String:buffer[250];
            (
Format(buffersizeof(buffer), "SELECT mdp FROM vip_membres WHERE steamid = '%s'"steamIdSave[client]))
            
            
PrintToChat(client"Votre SteamId : %s"steamIdSave[client]);

            if(
DEBUG == 1){
                
PrintToServer("DEBUG: Action:initPlayerBase (%s)"buffer);
            }
            
SQL_TQuery(dbSQLDataLoadbufferclient);
        }
}
public 
LoadMySQLBase(Handle:ownerHandle:hndl, const String:error[], any:data)
{
    if (
hndl == INVALID_HANDLE)
    {
        
PrintToServer("Failed to connect: %s"error)
        
db INVALID_HANDLE;
        return;
    } else {
        
PrintToServer("DEBUG: DatabaseInit (CONNECTED)");
    }

    
db hndl;

Can you help me plz ?
__________________

Last edited by mickael002; 02-21-2013 at 15:56.
mickael002 is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 02-21-2013 , 16:38   Re: Problem for query sql
Reply With Quote #2

Quote:
Originally Posted by mickael002 View Post
PHP Code:
            steamIdSave[client] = steamId
You can't copy arrays like this, you have to use strcopy to copy a String.

Quote:
PHP Code:
            (Format(buffersizeof(buffer), "SELECT mdp FROM vip_membres WHERE steamid = '%s'"steamIdSave[client])) 
Why did put this in ( ) ? You only have to put a ; at the end.
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
berni is offline
mickael002
Senior Member
Join Date: Jul 2010
Old 02-21-2013 , 16:43   Re: Problem for query sql
Reply With Quote #3

I have changed to :

PHP Code:
public get_data_forcmd(client){        
        if (
db != INVALID_HANDLE)
        {        
            
decl String:steamId[64];
            
GetClientAuthString(clientsteamIdsizeof(steamId));
            
strcopy(steamIdSave[client], sizeof(steamIdSave[client]), steamId);
            
            
decl String:buffer[250];
            
Format(buffersizeof(buffer), "SELECT mdp FROM vip_membres WHERE steamid = '%s'"steamIdSave[client]);
            
            
PrintToChat(client"Votre SteamId : %s"steamIdSave[client]);

            if(
DEBUG == 1){
                
PrintToServer("DEBUG: Action:initPlayerBase (%s)"buffer);
            }
            
SQL_TQuery(dbSQLDataLoadbufferclient);
    } 
But i have now a lot of errors :

- error 001: expected token: "]", but found "-identifier-" (line : strcopy(steamIdSave[client], sizeof(steamIdSave[client]), steamId); ) x2
- error 029: invalid expression, assumed zero (idem line)
fatal error 127: too many error message on one line
Quote:
Originally Posted by berni View Post
You can't copy arrays like this, you have to use strcopy to copy a String.



Why did put this in ( ) ? You only have to put a ; at the end.
__________________

Last edited by mickael002; 02-21-2013 at 16:43.
mickael002 is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 02-21-2013 , 17:01   Re: Problem for query sql
Reply With Quote #4

the client isn't relevant for sizeof() for the compiler.

Instead of:

PHP Code:
            decl String:steamId[64];
            
GetClientAuthString(clientsteamIdsizeof(steamId));
            
strcopy(steamIdSave[client], sizeof(steamIdSave[client]), steamId); 
You can just do:

PHP Code:
GetClientAuthString(clientsteamIdSave[client],  sizeof(steamIdSave[])); 
But I don't understand why there is a global array with size of 64.
If you want to keep track of SteamID's you have to use a dynamic array, which can hold unlimited steamID's.
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0

Last edited by berni; 02-21-2013 at 17:01.
berni is offline
mickael002
Senior Member
Join Date: Jul 2010
Old 02-21-2013 , 17:21   Re: Problem for query sql
Reply With Quote #5

Thanks !

PHP Code:
public get_data_forcmd(client){        
        if (
db != INVALID_HANDLE)
        {        
            
decl String:steamId[64];
            
GetClientAuthString(clientsteamIdsizeof(steamId));
            
            
decl String:buffer[250];
            
Format(buffersizeof(buffer), "SELECT mdp FROM vip_membres WHERE steamid = '%s';"steamId);
            
            
PrintToChat(client"Votre SteamId : %s"steamId);

            if(
DEBUG == 1){
                
PrintToServer("DEBUG: Action:initPlayerBase (%s)"buffer);
            }
            
SQL_TQuery(dbSQLDataLoadbufferclient);
        }

Working perfectly !

Quote:
Originally Posted by berni View Post
the client isn't relevant for sizeof() for the compiler.

Instead of:

PHP Code:
            decl String:steamId[64];
            
GetClientAuthString(clientsteamIdsizeof(steamId));
            
strcopy(steamIdSave[client], sizeof(steamIdSave[client]), steamId); 
You can just do:

PHP Code:
GetClientAuthString(clientsteamIdSave[client],  sizeof(steamIdSave[])); 
But I don't understand why there is a global array with size of 64.
If you want to keep track of SteamID's you have to use a dynamic array, which can hold unlimited steamID's.
__________________

Last edited by mickael002; 02-21-2013 at 17:22.
mickael002 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 12:19.


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