AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Run time error 5: memory access (https://forums.alliedmods.net/showthread.php?t=309337)

Number1 07-22-2018 05:33

Run time error 5: memory access
 
Hello folks. Im getting error:

PHP Code:

Run time error 5memory access 


Error line:

PHP Code:

new query[999]; 

PHP Code:

SQL_ThreadQuery(g_SqlX,"QueryHandle",query

Any suggest?

Celena Luna 07-22-2018 05:41

Re: Run time error 5: memory access
 
What did you put in query[]?

Number1 07-22-2018 07:44

Re: Run time error 5: memory access
 
Quote:

Originally Posted by Celena Luna (Post 2605409)
What did you put in query[]?

HTML Code:

format(query,1000,"INSERT into %s (name,authid,ip,alive,team,date,time,message,cmd,match_id) values ('%s','%s','%s','%d','%s','%s','%s','%s','%s','%s')",table,name,authid,ip,is_user_alive(id),TEAMNAME[_:team],datestr,timestr,message,cmd,szLine)
SQL_ThreadQuery(g_SqlX,"QueryHandle",query)


Celena Luna 07-22-2018 12:18

Re: Run time error 5: memory access
 
PHP Code:

format(query,1000,"INSERT into %s (name,authid,ip,alive,team,date,time,message,cmd,match_id) values ('%s','%s','%s','%d','%s','%s','%s','%s','%s','%s')",table,name,authid,ip,is_user_alive(id),TEAMNAME[_:team],datestr,timestr,message,cmd,szLine
SQL_ThreadQuery(g_SqlX,"QueryHandle",query

=>

PHP Code:

format(query,charsmax(query),"INSERT into %s (name,authid,ip,alive,team,date,time,message,cmd,match_id) values ('%s','%s','%s','%d','%s','%s','%s','%s','%s','%s')",table,name,authid,ip,is_user_alive(id),TEAMNAME[_:team],datestr,timestr,message,cmd,szLine
SQL_ThreadQuery(g_SqlX,"QueryHandle",query

the string is 999 so the len should be < 999.
The error give because you put 1000 there

Quote:

Originally Posted by Bugsy (Post 1276335)
As fysiks said, you will almost always use charsmax() when dealing with strings since 1 array cell must be reserved for a null character.


Natsheh 07-23-2018 07:44

Re: Run time error 5: memory access
 
Declare the variable(array) as static.


All times are GMT -4. The time now is 12:38.

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