胜利翌凡 发表于 2008-12-17 15:10:48

求教SQL

#include <amxmodx>
#include <amxmisc>
#include <dbi>
#define PLUGIN "testsql"
#define VERSION "1.0"
#define AUTHOR "1"
new host
new user
new pass
new tabname
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_cvar ("dbi_host", "127.0.0.1")
register_cvar ("dbi_user", "admin")
register_cvar ("dbi_pass", "admin")
register_cvar ("dbi_tabname", "cs")


get_cvar_string("dbi_host",host,32)
get_cvar_string("dbi_user",user,32)
get_cvar_string("dbi_pass",pass,32)
get_cvar_string("dbi_tabname",tabname,32)
set_task(5.0,"name")
}

public name () {

new Sql:dbc
new Result:result
new auth

dbc = dbi_connect(host,user,pass,tabname)
result = dbi_query (dbc, "SELECT * FROM admins")
while (dbi_nextrow(result) > 0 )
(
dbi_result (result,"auth",auth,32)
)
log_amx ("ID %s",auth)
dbi_close(dbc)

}

错误在哪??

jiunnwoei2629 发表于 2008-12-17 20:08:34

回复: 求教SQL

我有幫你看了一下
你的dbi_nextrow寫的方式有錯誤
你應該要多看一下dbi.inc一下

我已經幫你更正過了
也測試過了沒有出現錯誤
你拿去試試看吧(我順便把sma寫的標準化,習慣了 這樣看起來比較好看~ ~)

胜利翌凡 发表于 2008-12-17 20:43:24

回复: 求教SQL

谢谢你,我仔细看看,谢谢

zwfgdlc 发表于 2008-12-17 21:09:07

回复: 求教SQL


#include <amxmodx>
#include <amxmisc>
#include <dbi>
#define PLUGIN "testsql"
#define VERSION "1.0"
#define AUTHOR "1"
new host
new user
new pass
new tabname
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_cvar ("dbi_host", "127.0.0.1")
register_cvar ("dbi_user", "admin")
register_cvar ("dbi_pass", "admin")
register_cvar ("dbi_tabname", "cs")


get_cvar_string("dbi_host",host,32)
get_cvar_string("dbi_user",user,32)
get_cvar_string("dbi_pass",pass,32)
get_cvar_string("dbi_tabname",tabname,32)
set_task(5.0,"name")
}
public name () {

new Sql:dbc
new Result:result
new auth

dbc = dbi_connect(host,user,pass,tabname)
if(dbc==SQL_OK)
{
result = dbi_query (dbc, "SELECT * FROM admins");
if(result>RESULT_NONE)
{
do{
dbi_field(result,1,auth,32);
log_amx ("ID %s",auth);
}while(dbi_nextrow(result));
dbi_free_result(result);
dbi_close(dbc);
}
}
}
页: [1]
查看完整版本: 求教SQL