Raised This Month: $ Target: $400
 0% 

Need help with sql and amxx.


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
xd346
Junior Member
Join Date: Aug 2019
Old 08-26-2019 , 15:12   Need help with sql and amxx.
Reply With Quote #1

Hi, I want to make a plugin that will store data in a database I made using phpMyAdmin. I'm also using wamp.
I've been using this guide https://wiki.alliedmods.net/Advanced...ng_(AMX_Mod_X).

PHP Code:
#include <amxmodx>
#include <dbi>
#include <amxx\amxmod_compat\mysql>
#include <esf>
#include <ipci\ascend>
#include <esf_util>
#include <fun>
#include <fakemeta>
#include <fakemeta_const>
#include <hamsandwich> 




new Sql:databaseconnection
new err[255]
new 
errNum

public plugin_init() 
{
  
register_plugin("Database Data","1.0","")
  
register_clcmd("say steamid","plugintriggertest");
  
RegisterHam(Ham_Killed"player""fwdPlayerDeath"0);
  
  
databaseconnectiondbi_connect("127.0.0.1""root""""esf_data")
  if (
databaseconnection SQL_OK
    {
        
        
errNum dbi_error(databaseconnectionerr254)
        
server_print("error1: %s|%d"errerrNum)
    }
}

new 
steamid[32]
new 
username[40]
new 
powerlevel
new charactername[32]
new 
characterid 

public plugintriggertest(id)
{
    
client_print(id,print_chat,"error1: %s|%d"errerrNum)
    
get_user_name(id,username,40)
    
get_user_authididsteamid32)
    
powerlevel=getClientPL(id);
    
characterid=getClientCLASS(id);
    
getClassDATAvcharacteridcxNamecharactername32 );
    new 
Result:ret dbi_query(databaseconnection,"INSERT INTO general_information (SteamID,Username,Character_1,Powerlevel_1) VALUES ('%s','%s','%s',%i);",steamid,username,charactername,powerlevel
    
//new Result:ret = dbi_query(databaseconnection,"INSERT INTO general_information (SteamID,Username,Character_1,Powerlevel_1) VALUES ('%s','%s','%s',%i);",steamid,username,charactername,powerlevel) 
    //client_print(id,print_chat,"INSERT INTO general_information (SteamID,Username,Character_1,Powerlevel_1) VALUES ('%s','%s','%s',%i);",steamid,username,charactername,powerlevel)
    
if (ret RESULT_NONE
    {
        new 
err[255]
        new 
errNum dbi_error(databaseconnectionerr254)
        
server_print("error2: %s|%d"errerrNum)
    }
    
dbi_close(databaseconnection)

If I run the query through the mysql console it works, but when I try running it ingame I get this error:
PHP Code:
L 08/26/2019 21:06:26: [SQLITEInvalid DBI handle 0
L 08
/26/2019 21:06:26: [AMXXDisplaying debug trace (plugin "DBContent.amxx")
L 08/26/2019 21:06:26: [AMXXRun time error 10native error (native "dbi_query")
L 08/26/2019 21:06:26: [AMXX]    [0DBContentSQLX.sma::plugintriggertest (line 48
I'm kinda new to amxx scripting so any help would be appreciated.
xd346 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 17:25.


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