SA-MP Forums Archive
mysql_function_query - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: mysql_function_query (/showthread.php?tid=554351)



mysql_function_query - TonyII - 03.01.2015

Hey guys, so whenever I got my code like this.
pawn Code:
mysql_function_query(g_Handle, "CREATE TABLE IF NOT EXISTS `users` ( \
        `id` int(11) NOT NULL AUTO_INCREMENT, \
        `name` varchar(24) NOT NULL, \
        `pass` varchar(129) NOT NULL, \
        `health` float NOT NULL, \
        `X` float NOT NULL, \
        `Y` float NOT NULL, \
        `Z` float NOT NULL, \
        `A` float NOT NULL, \
        `interior` int(2) NOT NULL, \
        `vw` int(11) NOT NULL, \
        `skin` int(3) NOT NULL, \
        `banned` int(3) NOT NULL, \
        `primary` int(3) NOT NULL, \
        `primaryammo` int(5) NOT NULL, \
        `secondary` int(3) NOT NULL, \
        `secondaryammo` int(5) NOT NULL, \
        PRIMARY KEY (`id`) \
    )"
, false, "SendQuery", "");
I get: error 075: input line too long (after substitutions)

Whenever I use strcat like this
pawn Code:
strcat(qry1,"CREATE TABLE IF NOT EXISTS `users` ( \
        `id` int(11) NOT NULL AUTO_INCREMENT, \
        `name` varchar(24) NOT NULL, \
        `pass` varchar(129) NOT NULL, \
        `health` float NOT NULL, \
        `X` float NOT NULL, \
        `Y` float NOT NULL, \
        `Z` float NOT NULL, \
        `A` float NOT NULL, "
);
    strcat(qry1,"`interior` int(2) NOT NULL, \
        `vw` int(11) NOT NULL, \
        `skin` int(3) NOT NULL, \
        `banned` int(3) NOT NULL, \
        `primary` int(3) NOT NULL, \
        `primaryammo` int(5) NOT NULL, \
        `secondary` int(3) NOT NULL, \
        `secondaryammo` int(5) NOT NULL, PRIMARY KEY (`id`))"
, false, "SendQuery", "");
    mysql_function_query(g_Handle, qry1);
I get: error 017: undefined symbol "mysql_function_query"

Please note that it works and compiles fine when I do it like this.

pawn Code:
mysql_function_query(g_Handle, "CREATE TABLE IF NOT EXISTS `users` ( \
        `id` int(11) NOT NULL AUTO_INCREMENT, \
        `name` varchar(24) NOT NULL, \
        `pass` varchar(129) NOT NULL, \
        `health` float NOT NULL, \
        `X` float NOT NULL, \
        `Y` float NOT NULL, \
        `Z` float NOT NULL, \
        `A` float NOT NULL, \
        `interior` int(2) NOT NULL, \
        `vw` int(11) NOT NULL, \
        `skin` int(3) NOT NULL, \
        PRIMARY KEY (`id`) \
    )"
, false, "SendQuery", "");
Left out 5 of the lines.


AW: mysql_function_query - CutX - 03.01.2015

you get the undefined symbol error because you used strcat incorrectly.
strcat has three params.
1st being the destination
2nd the source
3rd the max. length (which is the size of the destination by default so we don't have to set it)

see:
pawn Code:
strcat(qry1,"CREATE TABLE IF NOT EXISTS `users` ( \
        `id` int(11) NOT NULL AUTO_INCREMENT, \
        `name` varchar(24) NOT NULL, \
        `pass` varchar(129) NOT NULL, \
        `health` float NOT NULL, \
        `X` float NOT NULL, \
        `Y` float NOT NULL, \
        `Z` float NOT NULL, \
        `A` float NOT NULL, "
);
strcat(qry1,"`interior` int(2) NOT NULL, \
        `vw` int(11) NOT NULL, \
        `skin` int(3) NOT NULL, \
        `banned` int(3) NOT NULL, \
        `primary` int(3) NOT NULL, \
        `primaryammo` int(5) NOT NULL, \
        `secondary` int(3) NOT NULL, \
        `secondaryammo` int(5) NOT NULL, PRIMARY KEY (`id`))"
);//, false, "SendQuery", "");
    mysql_function_query(g_Handle, qry1);
after "PRIMARY KEY (`id`))" you offered 3 unknown params to strcat.
false, "sendQuery" and ""


Re: mysql_function_query - TonyII - 03.01.2015

I still get the same error tho


AW: Re: mysql_function_query - CutX - 03.01.2015

Quote:
Originally Posted by TonyII
View Post
I still get the same error tho
hmm...
but you have the "mysql_function_query" function in your script, right?
(i couldn't find it on the wiki, it must be something custom)


Re: AW: Re: mysql_function_query - CrazyChoco - 03.01.2015

Quote:
Originally Posted by CutX
View Post
hmm...
but you have the "mysql_function_query" function in your script, right?
(i couldn't find it on the wiki, it must be something custom)
It's not custom. This feature has been a part of the BlueG mysql plugin since R7.


AW: Re: AW: Re: mysql_function_query - CutX - 03.01.2015

Quote:
Originally Posted by CrazyChoco
View Post
It's not custom. This feature has been a part of the BlueG mysql plugin since R7.
ah! ye ye of course!
now i remember

it's used like this:
pawn Code:
mysql_function_query(g_Handle, "CREATE TABLE IF NOT EXISTS `accounts` ( \
    `ID` int(6) NOT NULL AUTO_INCREMENT, \
    `Name` varchar(24) NOT NULL, \
    `Pass` varchar(170) NOT NULL, \
    `Salt` varchar(20) NOT NULL, \
    `IP` varchar(16) DEFAULT NULL, \
    `SecCode` varchar(10) NOT NULL,\
    `Score` int(6) NOT NULL, \
    `ALevel` int(1) NOT NULL,\
    `Money` int(13) NOT NULL, \
    `Bank` int(13) NOT NULL, \
    `Wanted` int(4) NOT NULL, \
    `RegDate` varchar(20) NOT NULL, \
    PRIMARY KEY (`ID`) \
    )"
, false, "SendQuery", "");
but you used it like this:
pawn Code:
mysql_function_query(g_Handle, qry1);
it's totally okey that you store the query in a string (qry1) thats not the problem.
youre just missing the other 3 params: false, "SendQuery", ""

prototype:
pawn Code:
native mysql_function_query(connectionHandle, query[], bool:cache, callback[], format[], {Float,_}:...);
it should look like
pawn Code:
strcat(qry1,"CREATE TABLE IF NOT EXISTS `users` ( \
        `id` int(11) NOT NULL AUTO_INCREMENT, \
        `name` varchar(24) NOT NULL, \
        `pass` varchar(129) NOT NULL, \
        `health` float NOT NULL, \
        `X` float NOT NULL, \
        `Y` float NOT NULL, \
        `Z` float NOT NULL, \
        `A` float NOT NULL, "
);
strcat(qry1,"`interior` int(2) NOT NULL, \
        `vw` int(11) NOT NULL, \
        `skin` int(3) NOT NULL, \
        `banned` int(3) NOT NULL, \
        `primary` int(3) NOT NULL, \
        `primaryammo` int(5) NOT NULL, \
        `secondary` int(3) NOT NULL, \
        `secondaryammo` int(5) NOT NULL, PRIMARY KEY (`id`))"
);
    mysql_function_query(g_Handle, qry1, false, "SendQuery", "");



Re: mysql_function_query - TonyII - 03.01.2015

Thanks, that removed the error, but left me off with 2 warnings.
pawn Code:
strcat(qry1,"CREATE TABLE IF NOT EXISTS `users` ( \
        `id` int(11) NOT NULL AUTO_INCREMENT, \
        `name` varchar(24) NOT NULL, \
        `pass` varchar(129) NOT NULL, \
        `health` float NOT NULL, \
        `X` float NOT NULL, \
        `Y` float NOT NULL, \
        `Z` float NOT NULL, \
        `A` float NOT NULL, "
); // warning 217: loose indentation
strcat(qry1,"`interior` int(2) NOT NULL, \
        `vw` int(11) NOT NULL, \
        `skin` int(3) NOT NULL, \
        `banned` int(3) NOT NULL, \
        `primary` int(3) NOT NULL, \
        `primaryammo` int(5) NOT NULL, \
        `secondary` int(3) NOT NULL, \
        `secondaryammo` int(5) NOT NULL, PRIMARY KEY (`id`))"
);
    mysql_function_query(g_Handle, qry1, false, "SendQuery", ""); // warning 217: loose indentation
EDIT: After compiling it the second time the warnings dissapeard, thanks again.


AW: Re: mysql_function_query - CutX - 03.01.2015

Quote:
Originally Posted by TonyII
View Post
Thanks, that removed the error, but left me off with 2 warnings.
pawn Code:
strcat(qry1,"CREATE TABLE IF NOT EXISTS `users` ( \
        `id` int(11) NOT NULL AUTO_INCREMENT, \
        `name` varchar(24) NOT NULL, \
        `pass` varchar(129) NOT NULL, \
        `health` float NOT NULL, \
        `X` float NOT NULL, \
        `Y` float NOT NULL, \
        `Z` float NOT NULL, \
        `A` float NOT NULL, "
); // warning 217: loose indentation
strcat(qry1,"`interior` int(2) NOT NULL, \
        `vw` int(11) NOT NULL, \
        `skin` int(3) NOT NULL, \
        `banned` int(3) NOT NULL, \
        `primary` int(3) NOT NULL, \
        `primaryammo` int(5) NOT NULL, \
        `secondary` int(3) NOT NULL, \
        `secondaryammo` int(5) NOT NULL, PRIMARY KEY (`id`))"
);
    mysql_function_query(g_Handle, qry1, false, "SendQuery", ""); // warning 217: loose indentation
EDIT: After compiling it the second time the warnings dissapeard, thanks again.
naturaly, code indentation only causes warnings (ppls tend to ignore them)
but it's important for you too that the code looks... proper..
i mean you spot mistakes faster cuz the code looks clear
Allman style is good for a clear view of your code (i use it myself)


Re: mysql_function_query - TonyII - 03.01.2015

That makes sense now, I had plenty of the same warnings without knowing what caused it


Re: mysql_function_query - CoaPsyFactor - 03.01.2015

update your plugin and include file.