Junior Member
|
08-11-2015
, 12:40
Plugins to database
|
#1
|
Hello everyone,
i need help for codding i dont know c# codding.. Years ago i was using it and Exolent helped me but now its giving error..
Code :
Code:
#include <amxmodx>
#include <sqlx>
#define SQL_HOST "localhost"
#define SQL_USER "*****"
#define SQL_PASS "*****"
#define SQL_DB "*******"
public plugin_init()
{
register_plugin("Plugin List to SQL", "0.0.1", "Exolent");
register_concmd("amx_musti", "musti", ADMIN_CFG, "asdas")
}
public plugin_cfg()
{
new Handle:tuple = SQL_MakeDbTuple(SQL_HOST, SQL_USER, SQL_PASS, SQL_DB);
if(tuple == Empty_Handle) return log_amx("Failed to make SQL tuple");
new errcode, error[128];
new Handle:db = SQL_Connect(tuple, errcode, error, charsmax(error));
if(db == Empty_Handle) return log_amx("Failed connecting to db (%d): %s", errcode, error);
new Handle:query = SQL_PrepareQuery(db,
"CREATE TABLE IF NOT EXISTS plugin_list \
(filename VARCHAR(64) NOT NULL, \
name VARCHAR(64) NOT NULL, \
author VARCHAR(64) NOT NULL, \
version VARCHAR(32) NOT NULL);");
if(!SQL_Execute(query))
{
SQL_QueryError(query, error, charsmax(error));
log_amx("Error on create table: %s", error);
}
SQL_FreeHandle(query);
query = SQL_PrepareQuery(db, "DELETE FROM plugin_list;");
if(!SQL_Execute(query))
{
SQL_QueryError(query, error, charsmax(error));
log_amx("Error on emptying table: %s", error);
}
SQL_FreeHandle(query);
new filename[64], name[64], author[64], version[32];
new pluginsnum = get_pluginsnum();
static query_all[1024];
new len = copy(query_all, charsmax(query_all),
"INSERT INTO plugin_list \
(filename, name, author, version) \
VALUES");
for(new i = 0; i < pluginsnum; i++)
{
get_plugin(i, filename, charsmax(filename), name, charsmax(name), version, charsmax(version), author, charsmax(author));
len += formatex(query_all[len], charsmax(query_all) - len, "%s (^"%s^", ^"%s^", ^"%s^", ^"%s^")", i ? "," : "", filename, name, author, version);
}
query = SQL_PrepareQuery(db, "%s;", query_all);
if(!SQL_Execute(query))
{
SQL_QueryError(query, query_all, charsmax(query_all));
log_amx("Error on adding plugins: %s", query_all);
}
SQL_FreeHandle(query);
SQL_FreeHandle(db);
return 1;
}
public musti()
{
new Handle:tuple = SQL_MakeDbTuple(SQL_HOST, SQL_USER, SQL_PASS, SQL_DB);
if(tuple == Empty_Handle) return log_amx("Failed to make SQL tuple");
new errcode, error[128];
new Handle:db = SQL_Connect(tuple, errcode, error, charsmax(error));
if(db == Empty_Handle) return log_amx("Failed connecting to db (%d): %s", errcode, error);
new Handle:query = SQL_PrepareQuery(db,
"CREATE TABLE IF NOT EXISTS plugin_list \
(filename VARCHAR(64) NOT NULL, \
name VARCHAR(64) NOT NULL, \
author VARCHAR(64) NOT NULL, \
version VARCHAR(32) NOT NULL);");
if(!SQL_Execute(query))
{
SQL_QueryError(query, error, charsmax(error));
log_amx("Error on create table: %s", error);
}
SQL_FreeHandle(query);
query = SQL_PrepareQuery(db, "DELETE FROM plugin_list;");
if(!SQL_Execute(query))
{
SQL_QueryError(query, error, charsmax(error));
log_amx("Error on emptying table: %s", error);
}
SQL_FreeHandle(query);
new filename[64], name[64], author[64], version[32];
new pluginsnum = get_pluginsnum();
static query_all[1024];
new len = copy(query_all, charsmax(query_all),
"INSERT INTO plugin_list \
(filename, name, author, version) \
VALUES");
for(new i = 0; i < pluginsnum; i++)
{
get_plugin(i, filename, charsmax(filename), name, charsmax(name), version, charsmax(version), author, charsmax(author));
len += formatex(query_all[len], charsmax(query_all) - len, "%s (^"%s^", ^"%s^", ^"%s^", ^"%s^")", i ? "," : "", filename, name, author, version);
}
query = SQL_PrepareQuery(db, "%s;", query_all);
if(!SQL_Execute(query))
{
SQL_QueryError(query, query_all, charsmax(query_all));
log_amx("Error on adding plugins: %s", query_all);
}
SQL_FreeHandle(query);
SQL_FreeHandle(db);
return 1;
}
And Error giving at console is ;
Code:
[musti.amxx] Error on adding plugins: 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 '"adminvote.a' at line 1
I tried to diffrent version of MYSQL on Cpanel, it doesnt work..
Thank you
Regards
|
|