AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   using sql with amxx (https://forums.alliedmods.net/showthread.php?t=22915)

Sonic7145 01-06-2006 20:07

using sql with amxx
 
pruned

Hawk552 01-06-2006 20:32

Read some plugins that use SQL. I think your best bet would probably be to search for plugins by Suicid3, he uses SQL a lot.

Xanimos 01-06-2006 21:07

Quote:

Originally Posted by Hawk552
Read some plugins that use SQL. I think your best bet would probably be to search for plugins by Suicid3, he uses SQL a lot.

Not a lot. lol. But yes I do. A lot of mine use files not SQL.

Des12 01-06-2006 23:17

Bascially like this:
Code:
dbc = dbi_connect(host,username,password,dbname,error,32) //have to assign own info for the first 4 if (dbc == SQL_FAILED) {         server_print("[AMXX] Could Not Connect To SQL Database^n") }

Xanimos 01-07-2006 17:00

That wont quite work. Use:
Code:
sql = dbi_connect(host,username,password,dbname,error,125) if( sql > SQL_FAILED ) {     server_print( "[AMXX] Connected")    //If this point is reached you need to use dbi_close( sql ) } else {     server_print("[AMXX] Failed to connect. Error: %s" , error)     //If this point is reached you do not use dbi_close( sql ) }

teame06 01-07-2006 17:59

Quote:

Originally Posted by Sonic7145
and the problem, when a client joins:

L 01/07/2006 - 14:54:11: [MYSQL] Invalid database handle 0
L 01/07/2006 - 14:54:11: [AMXX] Run time error 10 (plugin "sqltest.amxx") - debug not enabled!
L 01/07/2006 - 14:54:11: [AMXX] To enable debug mode, add "debug" after the plugin name in plugins.ini (without quotes).


Hmm... Let see.. This is trying to tell you to enable debug on that plugin =)

Xanimos 01-07-2006 18:20

make
Code:
new Sql:dbc
global and then take it out of both functions.

Xanimos 01-07-2006 20:19

Please readup on how to use dbi you cannot use dbi_numrows(result) if the result failed. use something similar to the following.
Code:
result = dbi_query(dbc,"SELECT * FROM `steamids` WHERE `steamid` = '%s' LIMIT 0 , 1", usersteam) if( result <= RESULT_FAILED ) {     //Log failed message here } else if( result == RESULT_NONE ) {     //No results returned.     //Use dbi_free_result(result) } else {     //Results returned use dbi_result() or dbi_field() now.     //Use dbi_free_result( result ) }


All times are GMT -4. The time now is 15:55.

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