Raised This Month: $ Target: $400
 0% 

MySQL Compile Error [URGENT]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Fr0Gs
New Member
Join Date: Jan 2007
Old 01-12-2007 , 11:01   MySQL Compile Error [URGENT]
Reply With Quote #1

I got this code of the mysql examples but when i compile i get this error

Code:
// C:\Program Files\Valve\Steam\SteamApps\fr0gso\counter-strike\cstrike\addons\a
mxmodx\scripting\banbot.sma(27) : error 029: invalid expression, assumed zero
// C:\Program Files\Valve\Steam\SteamApps\fr0gso\counter-strike\cstrike\addons\a
mxmodx\scripting\banbot.sma(27) : error 029: invalid expression, assumed zero
// C:\Program Files\Valve\Steam\SteamApps\fr0gso\counter-strike\cstrike\addons\a
mxmodx\scripting\banbot.sma(28) : error 029: invalid expression, assumed zero
// C:\Program Files\Valve\Steam\SteamApps\fr0gso\counter-strike\cstrike\addons\a
mxmodx\scripting\banbot.sma(28) : error 029: invalid expression, assumed zero
// C:\Program Files\Valve\Steam\SteamApps\fr0gso\counter-strike\cstrike\addons\a
mxmodx\scripting\banbot.sma(29) : error 029: invalid expression, assumed zero
// C:\Program Files\Valve\Steam\SteamApps\fr0gso\counter-strike\cstrike\addons\a
mxmodx\scripting\banbot.sma(29) : error 029: invalid expression, assumed zero
// C:\Program Files\Valve\Steam\SteamApps\fr0gso\counter-strike\cstrike\addons\a
mxmodx\scripting\banbot.sma(30) : error 029: invalid expression, assumed zero
// C:\Program Files\Valve\Steam\SteamApps\fr0gso\counter-strike\cstrike\addons\a
mxmodx\scripting\banbot.sma(30) : error 029: invalid expression, assumed zero
// C:\Program Files\Valve\Steam\SteamApps\fr0gso\counter-strike\cstrike\addons\a
mxmodx\scripting\banbot.sma(33) : error 029: invalid expression, assumed zero
// C:\Program Files\Valve\Steam\SteamApps\fr0gso\counter-strike\cstrike\addons\a
mxmodx\scripting\banbot.sma(33) : error 029: invalid expression, assumed zero
// C:\Program Files\Valve\Steam\SteamApps\fr0gso\counter-strike\cstrike\addons\a
mxmodx\scripting\banbot.sma(34) : error 029: invalid expression, assumed zero
// C:\Program Files\Valve\Steam\SteamApps\fr0gso\counter-strike\cstrike\addons\a
mxmodx\scripting\banbot.sma(34) : error 029: invalid expression, assumed zero
// C:\Program Files\Valve\Steam\SteamApps\fr0gso\counter-strike\cstrike\addons\a
mxmodx\scripting\banbot.sma(34) : warning 215: expression has no effect
// C:\Program Files\Valve\Steam\SteamApps\fr0gso\counter-strike\cstrike\addons\a
mxmodx\scripting\banbot.sma(34) : error 001: expected token: ";", but found "if"
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <dbi>

#define PLUGIN "MySQL Example"
#define VERSION "1.0"
#define AUTHOR "Sphinx"

//The MySQL DataBase Connection.
new Sql:dbc 

//The result, it tells us if the command/query worked and such
//Used like this
//"result = dbi_query(dbc, "The command sent to the database")
new Result:result

//We need to check to see if the player is new, so we have this.
//If its 0 that means he is completely new to the server
//If its above 0 that means he has a recorded time.
new g_ConnectTime[33]

//What we are using the MySQL database for, storing the information
//You can alter this anyway you like.
new g_PlayerInfo[33]

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
//Initializes the connection
    
set_task(0.1,"sql_init")
}
public 
client_disconnect(id) {
    
//Checks to make sure we have a connection, if we don't then don't continue.
    
if (dbc == SQL_FAILED) {
        return 
PLUGIN_HANDLED;
    }
    
//We need to retrieve the Steamid
    
new authid[32]
    
get_user_authid(id,authid,31)
    
    
//We retrieve how long they have been on the server, on this connection.
    //It will get stored into ConnectTime,
    
new playtime get_user_time (id)
    
    
//This one will check to see that the player has a entry set up. It will just echo in the
    //The database as "Empty Set" if he doesn't have one, so its harmless to have if he doesn't have
    //A slot.
    
result dbi_query(dbc,"SELECT * FROM tablename WHERE steamid = '%s'",authid)
    if (
result == RESULT_FAILED) {
        
log_amx("[MySQL Test] MySQL Query Failed!!")
        return 
PLUGIN_CONTINUE
        
// It failed for some reason, probably becuase DBC failed.
    
}
    
// We were talking about this earlier, 0 means create a fresh entry.
    
else if (g_ConnectTime[id]== 0) {
        
//This tells the database to create an entry, storing the players steamid, connect time, and w/e else you want.
        
result dbi_query(dbc,"INSERT INTO tablename (steamid, connecttime, playerinfo) values ('%s',%i,%i)",authid,playtime,g_PlayerInfo[id])
    }
    else {
            
//So we add this connection with the overall ConnectTime
        
new store_time = (playtime g_ConnectTime[id])
        
result dbi_query(dbc,"UPDATE tablename SET connecttime='%i'. playerinfo='%i' WHERE steamid='%s'",store_time,g_PlayerInfo[id],authid)
    }
    
// We have to free the result, so it can save properly.
    
dbi_free_result(result);
    return 
PLUGIN_CONTINUE;
}
public 
client_authorized(id) {
    if (
dbc == SQL_FAILED) {
        return 
PLUGIN_HANDLED;
    }
    new 
authid[32]
    
get_user_authid(id,authid,31)
    
result dbi_query(dbc,"SELECT * FROM tablename WHERE steamid = '%s'",authid)
    if (
result == RESULT_FAILED) {
        
log_amx("[MySQL Test] MySQL Query Failed!!")
        return 
PLUGIN_CONTINUE // Query failed! Sorry :P
    
}
    
// If he doesn't have a entry, we shall put up the defualts.
    
else if (result == RESULT_NONE) {
        
g_ConnectTime[id] = 0
        g_PlayerInfo
[id] = 0
    
}
    else {
        
dbi_nextrow(result// This retrieves data from your entry.
        //Loads up the recorded connect time, so we can tell that they have been on the server before
        
g_ConnectTime[id] = dbi_result(result,"connecttime")
        
        
//Loads up the information you stored last time they played.
        
g_PlayerInfo[id] = dbi_result(result"playerinfo")
    }
    
// You MUST free the result!
    
dbi_free_result(result)
    return 
PLUGIN_HANDLED;
}
public 
sql_init() {
    new 
error[256]
    
// The database connection, cvars work here too.
    
dbc dbi_connect("localhost""Username""password""databasename"error,255)
    if (
dbc == SQL_FAILED) {
        
log_amx("[MySQL Test] SQL Connection Failed = %s"error)
    }
    else 
        
//You don't have to do this, I just recommend it if you are going to make your plugin public.
        //This will Create a table to store the information to, with the proper values.
        
dbi_query(dbc,"CREATE TABLE IF NOT EXISTS `tablename` (`steamid` VARCHAR(32) NOT NULL,`connecttime` INT NOT NULL,`playerinfo` INT NOT NULL, PRIMARY KEY(`steamid`))")
    }
}
public 
plugin_end() {
    
// Close the connection
    
dbi_close(dbc);

Fr0Gs is offline
Salepate
Junior Member
Join Date: Jan 2007
Old 01-12-2007 , 11:55   Re: MySQL Compile Error [URGENT]
Reply With Quote #2

This code is nearly working you just forgot an open brace "{" line 103.
Your amxx compiler must be out of date.
Salepate is offline
Fr0Gs
New Member
Join Date: Jan 2007
Old 01-12-2007 , 13:03   Re: MySQL Compile Error [URGENT]
Reply With Quote #3

Yes i finaly got it to compile but for some reason its not querying into the database :S all the sql is correct
Fr0Gs is offline
Salepate
Junior Member
Join Date: Jan 2007
Old 01-12-2007 , 14:37   Re: MySQL Compile Error [URGENT]
Reply With Quote #4

Code:
result = dbi_query(dbc,"SELECT * FROM `tablename` WHERE `steamid` LIKE "%s", authid);

is more clean, but I'm starting to think that there is a collision between % (SQL joker term) and %s

By the way, is there any error printed ? (I mean client_print(); error type)
Salepate is offline
Fr0Gs
New Member
Join Date: Jan 2007
Old 01-12-2007 , 14:51   Re: MySQL Compile Error [URGENT]
Reply With Quote #5

Thats all the error says but the weird thing is its not making the table in the database so i dont know if its connecting or not even thought it is the correct info

Code:
L 01/13/2007 - 03:39:15: Start of error session.
L 01/13/2007 - 03:39:15: Info (map "de_aztec") (logfile "error_011307.log")
L 01/13/2007 - 03:39:15: [AMXX] Plugin ("hello.amxx") is setting itself as failed.
L 01/13/2007 - 03:39:15: [AMXX] Plugin says: 
L 01/13/2007 - 03:39:15: [AMXX] Displaying debug trace (plugin "hello.amxx")
L 01/13/2007 - 03:39:15: [AMXX] Run time error 1: forced exit 
L 01/13/2007 - 03:39:15: [AMXX]    [0] hello.sma::plugin_init (line 35)
Fr0Gs is offline
raa
Senior Member
Join Date: Oct 2005
Old 01-12-2007 , 15:08   Re: MySQL Compile Error [URGENT]
Reply With Quote #6

Quote:
Originally Posted by Fr0Gs View Post
Thats all the error says but the weird thing is its not making the table in the database so i dont know if its connecting or not even thought it is the correct info

Code:
L 01/13/2007 - 03:39:15: Start of error session.
L 01/13/2007 - 03:39:15: Info (map "de_aztec") (logfile "error_011307.log")
L 01/13/2007 - 03:39:15: [AMXX] Plugin ("hello.amxx") is setting itself as failed.
L 01/13/2007 - 03:39:15: [AMXX] Plugin says: 
L 01/13/2007 - 03:39:15: [AMXX] Displaying debug trace (plugin "hello.amxx")
L 01/13/2007 - 03:39:15: [AMXX] Run time error 1: forced exit 
L 01/13/2007 - 03:39:15: [AMXX]    [0] hello.sma::plugin_init (line 35)
check your logs for "[MySQL Test] MySQL Query Failed!!"
__________________
raa is offline
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 01-12-2007 , 15:06   Re: MySQL Compile Error [URGENT]
Reply With Quote #7

Post your entire script please.
__________________
Brad is offline
Fr0Gs
New Member
Join Date: Jan 2007
Old 01-12-2007 , 15:28   Re: MySQL Compile Error [URGENT]
Reply With Quote #8

Ok i try and put it in debug mode now im getting:

Code:
L 01/13/2007 - 06:51:49: Start of error session.
L 01/13/2007 - 06:51:49: Info (map "de_aztec") (logfile "error_011307.log")
L 01/13/2007 - 06:51:49: [SQLITE] Invalid DBI result handle -1
L 01/13/2007 - 06:51:49: [AMXX] Run time error 10 (plugin "banbot.amxx") (native "dbi_free_result") - debug not enabled!
L 01/13/2007 - 06:51:49: [AMXX] To enable debug mode, add "debug" after the plugin name in plugins.ini (without quotes).
Quote:
Originally Posted by Brad View Post
Post your entire script please.
Code:
#include <amxmodx>
#include <amxmisc>
#include <dbi>

#define PLUGIN "MySQL Example"
#define VERSION "1.0"
#define AUTHOR "Sphinx"

//The MySQL DataBase Connection.
new Sql:dbc 

//The result, it tells us if the command/query worked and such
//Used like this
//"result = dbi_query(dbc, "The command sent to the database")
new Result:result

//We need to check to see if the player is new, so we have this.
//If its 0 that means he is completely new to the server
//If its above 0 that means he has a recorded time.
new g_ConnectTime[33]

//What we are using the MySQL database for, storing the information
//You can alter this anyway you like.
new g_PlayerInfo[33]

public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)

//Initializes the connection
set_task(0.1,"sql_init")
}
public client_disconnect(id) {
    //Checks to make sure we have a connection, if we don't then don't continue.
    if (dbc == SQL_FAILED) {
        return PLUGIN_HANDLED;
    }
//We need to retrieve the Steamid
new authid[32]
get_user_authid(id,authid,31)

    //We retrieve how long they have been on the server, on this connection.
    //It will get stored into ConnectTime,
    new playtime = get_user_time (id)
    //This one will check to see that the player has a entry set up. It will just echo in the
    //The database as "Empty Set" if he doesn't have one, so its harmless to have if he doesn't have
    //A slot.
    result = dbi_query(dbc,"SELECT * FROM tablename WHERE steamid = '%s'",authid)
    if (result == RESULT_FAILED) {
        log_amx("[MySQL Test] MySQL Query Failed!!")
        return PLUGIN_CONTINUE
    // It failed for some reason, probably becuase DBC failed.
    }
    // We were talking about this earlier, 0 means create a fresh entry.
    else if (g_ConnectTime[id]== 0) {
        //This tells the database to create an entry, storing the players steamid, connect time, and w/e else you want.
        result = dbi_query(dbc,"INSERT INTO tablename (steamid, connecttime, playerinfo) values ('%s',%i,%i)",authid,playtime,g_PlayerInfo[id])
    }
    else {
        //So we add this connection with the overall ConnectTime
        new store_time = (playtime + g_ConnectTime[id])
        result = dbi_query(dbc,"UPDATE tablename SET connecttime='%i'. playerinfo='%i' WHERE steamid='%s'",store_time,g_PlayerInfo[id],authid)
    }
    // We have to free the result, so it can save properly.
    dbi_free_result(result);
    return PLUGIN_CONTINUE;
}
public client_authorized(id) {
    if (dbc == SQL_FAILED) {
        return PLUGIN_HANDLED;
    }
    new authid[32]
    get_user_authid(id,authid,31)
    result = dbi_query(dbc,"SELECT * FROM tablename WHERE steamid = '%s'",authid)
    if (result == RESULT_FAILED) {
        log_amx("[MySQL Test] MySQL Query Failed!!")
        return PLUGIN_CONTINUE // Query failed! Sorry :P
    }
    // If he doesn't have a entry, we shall put up the defualts.
    else if (result == RESULT_NONE) {
        g_ConnectTime[id] = 0
        g_PlayerInfo[id] = 0
    }
    else {
        dbi_nextrow(result) // This retrieves data from your entry.
        //Loads up the recorded connect time, so we can tell that they have been on the server before
        g_ConnectTime[id] = dbi_result(result,"connecttime")
        
        //Loads up the information you stored last time they played.
        g_PlayerInfo[id] = dbi_result(result, "playerinfo")
    }
    // You MUST free the result!
    dbi_free_result(result)
    return PLUGIN_HANDLED;
}
public sql_init() {
    new error[256]
    // The database connection, cvars work here too.
    dbc = dbi_connect("deasdfnp.silvsdfa-hsdostisdfgng.com", "deanpsdf_banbot", "rsdgdfg", "deandfsp_banbot", error,255)
    if (dbc == SQL_FAILED) {
        log_amx("[MySQL Test] SQL Connection Failed = %s", error)
    }
    else {
        //You don't have to do this, I just recommend it if you are going to make your plugin public.
        //This will Create a table to store the information to, with the proper values.
        dbi_query(dbc,"CREATE TABLE IF NOT EXISTS `tablename` (`steamid` VARCHAR(32) NOT NULL,`connecttime` INT NOT NULL,`playerinfo` INT NOT NULL, PRIMARY KEY(`steamid`))")
    }
}
public plugin_end() {
    // Close the connection
    dbi_close(dbc);
}

Last edited by Fr0Gs; 01-12-2007 at 15:47.
Fr0Gs is offline
Reply


Thread Tools
Display Modes

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 22:31.


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