AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] MySQL Simple save problem (https://forums.alliedmods.net/showthread.php?t=282028)

KaLoIaN 04-27-2016 03:15

[HELP] MySQL Simple save problem
 
http://pastebin.com/MuXMnHmj

As you see plugin_end function is quoted because it gives me error : [MySQL] Invalid handle: 0

The variable: escapes just does not saves.. I haven't got any errors from the plugin.


P.S. I put the code in pastebin because when I try to post the thread with the code - cloudflare of the forum does not allows me (maybe because of the sql symbols idk)..

SpeeDeeR 04-27-2016 05:51

Re: [HELP] MySQL Simple save problem
 
Doesn't
PHP Code:

"UPDATE `zmescape` SET `escapes` = '%i' WHERE `escapes`.`name` = '%s' 

has to be
PHP Code:

"UPDATE `zmescape` SET `escapes` = '%i' WHERE `zmescape`.`name` = '%s' 

You don't need to specify the column's table since you are updating it.

PHP Code:

"UPDATE `zmescape` SET `escapes` = '%i' WHERE `name` = '%s' 


KaLoIaN 04-27-2016 08:19

Re: [HELP] MySQL Simple save problem
 
Here is how I made the update line:

Code:

format(szTemp,charsmax(szTemp),"UPDATE `zmescape` SET `escapes` = '%i' WHERE `zmescape`.`name` = '%s';",escapes[id], szName)
But it's still not working. It just does not saves.

KaLoIaN 04-28-2016 16:45

Re: [HELP] MySQL Simple save problem
 
Somebody?

gabuch2 04-29-2016 08:37

Re: [HELP] MySQL Simple save problem
 
PHP Code:

format(szTemp,charsmax(szTemp),"UPDATE `zmescape` SET `escapes` = '%i' WHERE `zmescape`.`name` = '%s';",escapes[id], szName

This is redundant

>>

PHP Code:

format(szTemp,charsmax(szTemp),"UPDATE `zmescape` SET `escapes` = '%i' WHERE `name` = '%s';",escapes[id], szName

You don't need to specify the table if you're manipulating only one.

KaLoIaN 04-30-2016 08:49

Re: [HELP] MySQL Simple save problem
 
Quote:

Originally Posted by Shattered Heart Lynx (Post 2415166)
PHP Code:

format(szTemp,charsmax(szTemp),"UPDATE `zmescape` SET `escapes` = '%i' WHERE `zmescape`.`name` = '%s';",escapes[id], szName

This is redundant

>>

PHP Code:

format(szTemp,charsmax(szTemp),"UPDATE `zmescape` SET `escapes` = '%i' WHERE `name` = '%s';",escapes[id], szName

You don't need to specify the table if you're manipulating only one.

Again it does not save anything ..... :nono::shock::cry:

KaLoIaN 05-01-2016 12:51

Re: [HELP] MySQL Simple save problem
 
Is it so damn difficult lol? No one has made an correct answer...

Bugsy 05-01-2016 14:45

Re: [HELP] MySQL Simple save problem
 
This doesn't appear to have anything to do with his SQL query.

Are you setting g_SqlTuple to 0 somewhere else in your code? Are you getting this error in any other places when you try to use g_SqlTuple?

KaLoIaN 05-01-2016 15:06

Re: [HELP] MySQL Simple save problem
 
g_SqlTuple is not set to 0 nowhere. And yes I am getting it everytime I am using this tutorial:

click me

but it seems to be not well written or I do somethin' bad..

The main problem is that it does not saves.

Bugsy 05-01-2016 15:45

Re: [HELP] MySQL Simple save problem
 
See if this works for you:
PHP Code:


#include <amxmodx>
#include <sqlx>

new Handle:g_SQLTuple g_szQueryCache2000 ];

new const 
SQL_CreateTable[] = "QUERY TO CREATE TABLE WHICH WAS BLOCKED BY SERVER";

public 
plugin_init() 
{
    
SQL_SetAffinity"sqlite" );
    
g_SQLTuple SQL_MakeDbTuple"" "" "" "MyDatabaseFile" );
    
    new 
Handle:SqlConnection ErrorCode;
    
SqlConnection SQL_Connectg_SQLTuple ErrorCode g_szQueryCache charsmaxg_szQueryCache ) );
    
    if( 
SqlConnection == Empty_Handle )
        
set_fail_stateg_szQueryCache );
    
    
RunQuerySqlConnection SQL_CreateTable );
}

public 
plugin_end() 
{
    
SQL_FreeHandleg_SQLTuple );
}

public 
RunQueryHandle:SQLConnection , const szQuery[] )
{
    new 
Handle:Query SQL_PrepareQuerySQLConnection szQuery );
    
    if( !
SQL_ExecuteQuery ) )
    {
        
SQL_QueryErrorQuery g_szQueryCache 100 );
        
set_fail_stateg_szQueryCache );
    }




All times are GMT -4. The time now is 18:37.

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