Raised This Month: $ Target: $400
 0% 

SQLx Tablename Variable problem


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
raa
Senior Member
Join Date: Oct 2005
Old 01-13-2007 , 22:24   SQLx Tablename Variable problem
Reply With Quote #1

I don't see how the plugin can't resolve the tablename

Code:
new g_sqlstats_table[64]

public plugin_cfg()
	{
	// Fetch the database info stated in sql.cfg
	get_cvar_string("amx_sql_host",g_host,63)
	get_cvar_string("amx_sql_user",g_user,63)
	get_cvar_string("amx_sql_pass",g_pass,63)
	get_cvar_string("amx_sql_db",g_db,63)
	get_cvar_string("amx_sqlstats_table", g_sqlstats_table,63)
	
	g_SqlTuple = SQL_MakeDbTuple(g_host,g_user,g_pass,g_db)
		
	// ok, we're ready to connect
	new ErrorCode,Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)
	if(SqlConnection == Empty_Handle)
		// stop the plugin with an error message
	set_fail_state(g_Error)
	
	new Handle:CREATE[1]
	// we must now prepare some random queries
	CREATE[0] = SQL_PrepareQuery(SqlConnection,"CREATE TABLE IF NOT EXISTS `%s` (`authid` VARCHAR( 32 ) NOT NULL, `name` VARCHAR( 32 ) NOT NULL , `date` TIMESTAMP( 10 ) NOT NULL , `score` INT NOT NULL ,`kills` INT NOT NULL , `teamkills` INT NOT NULL, `deaths` INT NOT NULL , `hits` INT NOT NULL , `shots` INT NOT NULL , `headshots` INT NOT NULL , `efficiency` DOUBLE (19,2) DEFAULT NULL, `accuracy` double(19,2) default NULL,`accuracyHS` double(19,2) default NULL, PRIMARY KEY(`authid`))",g_sqlstats_table)
	for(new Count;Count < 1;Count++)
		{
		// run the queries, check if they were alright
		// note that you can run the same query multiple times
		// we are not doing this here, but it's nice to have
		if(!SQL_Execute(CREATE[Count]))
			{
			// if there were any problems
			SQL_QueryError(CREATE[Count],g_Error,511)
			set_fail_state(g_Error)
		}
		
		// close the handle
		SQL_FreeHandle(CREATE[Count])
		
		
		// you free everything with SQL_FreeHandle
		SQL_FreeHandle(SqlConnection)
	}
	return PLUGIN_CONTINUE
}
error logfile
Code:
L 01/13/2007 - 17:56:16: Start of error session.
L 01/13/2007 - 17:56:16: Info (map "de_dust2") (logfile "error_011307.log")
L 01/13/2007 - 17:56:16: [AMXX] Plugin ("SQLx_tut.amxx") is setting itself as failed.
L 01/13/2007 - 17:56:16: [AMXX] Plugin says: Incorrect table name ''
L 01/13/2007 - 17:56:16: [AMXX] Displaying debug trace (plugin "SQLx_tut.amxx")
L 01/13/2007 - 17:56:16: [AMXX] Run time error 1: forced exit 
L 01/13/2007 - 17:56:16: [AMXX]    [0] SQLx_tut.sma::plugin_cfg (line 124)
And when I replace the `%s` with a name like "table1", in the "CREATE[0]" line, it logs an error saying incorrect table "mydatabase.table1".

The DBI line I'm trying to convert to SQLx is ;
Code:
dbi_query(g_dbc, "CREATE TABLE IF NOT EXISTS `%s` (`authid` VARCHAR( 32 ) NOT NULL, `name` VARCHAR( 32 ) NOT NULL , `date` TIMESTAMP( 10 ) NOT NULL , `score` INT NOT NULL ,`kills` INT NOT NULL , `teamkills` INT NOT NULL, `deaths` INT NOT NULL , `hits` INT NOT NULL , `shots` INT NOT NULL , `headshots` INT NOT NULL , `efficiency` DOUBLE (19,2) DEFAULT NULL, `accuracy` double(19,2) default NULL,`accuracyHS` double(19,2) default NULL, PRIMARY KEY(`authid`))", g_sqlstats_table)
__________________

Last edited by raa; 01-13-2007 at 22:27.
raa is offline
 



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:23.


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