How to use sscanf to split a SQL row?
#1

Hello people,


I have an SQL Row received like this: INT|STRING|INT|INT|INT|blablabla many more int's

So how do i use sscanf (or any other way) to get a certain value of that sql string between a '|' like the int after the 5th '|'
Reply
#2

pawn Код:
sscanf(query, "p<|>s[50]if", string, int, float)..
Reply
#3

sscanf(yourresultline,"p<|>is[64],iii", ... )
Reply
#4

Quote:
Originally Posted by Sergei
Посмотреть сообщение
sscanf(yourresultline,"p<|>is[64],iii", ... )
can you explain why the [64]?
Reply
#5

Quote:
Originally Posted by DaneAMattie
Посмотреть сообщение
can you explain why the [64]?
it follows the s which represents strings

s[stringsize]

check the sscanf topic for more info
Reply
#6

Quote:
Originally Posted by Hal
Посмотреть сообщение
it follows the s which represents strings

s[stringsize]

check the sscanf topic for more info
oke i did this:

Код:
sscanf(tmpSQLResult, "p<|>isiiiiiiiiiiiiiiiiiiiiiiiiiiii",
							  "", "", "", "", "", Wapen1, Wapen2, Wapen3, Wapen4, Wapen5, Wapen6, Wapen7, Wapen8, Wapen9);
but when i do a sendclientmessage it asks to add an array so i did (new Wapen1[5]; and SendClientMessage(playerid,COLOR_RED,Wapen1[4]); etc) now i see the client message as empty so its not filled with any value :S
Reply
#7

Quote:
Originally Posted by DaneAMattie
Посмотреть сообщение
oke i did this:

Код:
sscanf(tmpSQLResult, "p<|>isiiiiiiiiiiiiiiiiiiiiiiiiiiii",
							  "", "", "", "", "", Wapen1, Wapen2, Wapen3, Wapen4, Wapen5, Wapen6, Wapen7, Wapen8, Wapen9);
but when i do a sendclientmessage it asks to add an array so i did (new Wapen1[5]; and SendClientMessage(playerid,COLOR_RED,Wapen1[4]); etc) now i see the client message as empty so its not filled with any value :S
You dont need to put the string value where you call it, only in the new

SendClientMessage(playerid, COLOR_RED, Wapen);
Reply
#8

i have this:

pawn Код:
new Wapen1[35];
new Wapen2[35];
etc.


sscanf(tmpSQLResult, "p<|>isiiiiiiiiiiiiiiiiiiiiiiiiiiii", "", "", "", "", "", Wapen1, Wapen2, Wapen3, Wapen4, Wapen5, Wapen6, Wapen7, Wapen8, Wapen9, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "");

        SendClientMessageToAll(COLOR_RED, tmpSQLResult);//This result thing works but the split results not so
        SendClientMessageToAll(COLOR_RED, Wapen1);// this one is empty :(
Reply
#9

Use explode.
Reply
#10

Quote:
Originally Posted by WackoX
Посмотреть сообщение
Use explode.
.... how is this supposed to helping me?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)