[Plugin] [REL] MySQL Plugin (Now on github!)
#41

Hi all!
I'm using this plugin, but I've got a question:
How can I make query, which gets back more than 1 row:
Here is my trying:
pawn Код:
new line[128], f=0, idx, field[MAX_PLAYER_NAME];
    CheckSQLConnection();
    mysql_query("SELECT * FROM forbnames");
    mysql_store_result();
    while(mysql_fetch_row(line)) {
      mysql_fetch_row_format(line, " ");
        field = strtok(line, idx);
        format(ForbidNames[f], MAX_PLAYER_NAME, field);
        f++;
    }
    mysql_free_result();
Thanx!
Reply
#42

pawn Код:
new
    data[128],
    row[512],
    i;
mysql_query("SELECT * FROM `forbnames`");
mysql_store_result();
while(mysql_fetch_row(row))
{
    mysql_fetch_field_row(data, "Name on mysql column");
    strmid(ForbidNames[f], data, 0, strlen(data), MAX_PLAYER_NAME);
    i++;
}
Haven't tested but it should work.
Reply
#43

Quote:
Originally Posted by ǝɹoɯ‾ʎ
pawn Код:
new
    data[128],
    row[512],
    i;
mysql_query("SELECT * FROM `forbnames`");
mysql_store_result();
while(mysql_fetch_row(row))
{
    mysql_fetch_field_row(data, "Name on mysql column");
    strmid(ForbidNames[f], data, 0, strlen(data), MAX_PLAYER_NAME);
    i++;
}
Haven't tested but it should work.
I wrote in this thread, I solved it.
I do it like u write it =), but 1 day ago.

But thank you!
Reply
#44

Sorry i Dont speak much english but i need Help, i like update my code for this mi old code are

Код:
	while(samp_mysql_strtok(arm, "|", armas)==1 && consulta[playerid] <= 6) //From 2nd call to the end you MUST call strtok without resultline
		{
		while(samp_mysql_strtok(arm, "|", "")==1 && consulta[playerid] <= 6) //From 2nd call to the end you MUST call strtok without resultline
		{
		consulta[playerid]++;
			if(consulta[playerid] == 1)
			{
	  	arma2[playerid] = strval(arm);
	  	if(arma2[playerid] == strval(""))
	  	arma2[playerid] = 0;
	  	printf("arma1: %s",arm); // palos
	  	}
	  	if(consulta[playerid] == 2)
			{
			arma3[playerid] = strval(arm);
			if(arma3[playerid] == strval(""))
	  	arma3[playerid] = 0;
			printf("arma2: %s",arm); // pistolitas
	  	}
	  	if(consulta[playerid] == 3)
			{
			arma4[playerid] = strval(arm);
			if(arma4[playerid] == strval(""))
	  	arma4[playerid] = 0;
			printf("arma3: %s",arm); //m4
	  	}
	  	if(consulta[playerid] == 4)
			{
			arma5[playerid] = strval(arm);
			if(arma5[playerid] == strval(""))
	  	arma5[playerid] = 0;
			printf("arma4: %s",arm); // escopetas
	  	}
	  	if(consulta[playerid] == 5)
			{
			arma6[playerid] = strval(arm);
			if(arma6[playerid] == strval(""))
	  	arma6[playerid] = 0;
			printf("arma5: %s",arm); // mp5
	  	}
		}
		}
Where i need change to update?

PD: Sorry my bad english thanks for you helpme
Reply
#45

nothing can helpme?
Reply
#46

Quote:
Originally Posted by elvago
nothing can helpme?
pawn Код:
new
    data[128],
    row[512],
    i;
mysql_query("SELECT * FROM `DATABASE_NAME`");
mysql_store_result();
while(mysql_fetch_row(row))
{
    mysql_fetch_field_row(data, "Name on mysql column");
    arma2[playerid] = strval(arm);
    if(arma2[playerid] == strval(""))
    arma2[playerid] = 0;
    printf("arma1: %s",arm); // palos
    mysql_fetch_field_row(data, "Name on mysql column");
    arma3[playerid] = strval(arm);
    if(arma3[playerid] == strval(""))
    arma3[playerid] = 0;
    printf("arma2: %s",arm); // pistolitas
    mysql_fetch_field_row(data, "Name on mysql column");
    arma4[playerid] = strval(arm);
    if(arma4[playerid] == strval(""))
    arma4[playerid] = 0;
    printf("arma3: %s",arm); //m4
    mysql_fetch_field_row(data, "Name on mysql column");
    arma5[playerid] = strval(arm);
    if(arma5[playerid] == strval(""))
    arma5[playerid] = 0;
    printf("arma4: %s",arm); // escopetas
    mysql_fetch_field_row(data, "Name on mysql column");
    arma6[playerid] = strval(arm);
    if(arma6[playerid] == strval(""))
    arma6[playerid] = 0;
    printf("arma5: %s",arm); // mp5
    i++;
}
If that current code works on the old mySQL, this should.
Reply
#47

Thx, but the server are crashed you can fix this?

PD: sorry my bad english
Reply
#48

now the error are
mysql_fetch_field_row(arm, "palos");

''palos'' are a colum

PD: Sorry my bad english, Thanks for help me
Reply
#49

every time i send "SELECT * FROM ..." and I call mysql_num_rows() i got all fine
but when ic call mysql_fetch_row(); the server crashes why?
if I call "SELECT `coloumnname` FROM ..." it worked fine.
Reply
#50

I use this:

Код:
	mysql_connect("127.0.0.1","root","samp","root");
	printf("Connecting done");
	
	mysql_query("SELECT money FROM gebruikers WHERE naam = 'Stijn'");
	mysql_store_result();
	new row[1];
	new i;
	while(mysql_fetch_row(row))
	{
		printf("%d", row[i]);
		i++;
	}
In my database, money would be 125, but in my serverprompt it shows 78, and after that the server crashes.
I think the problem is by the fetching, inserthing things to the database is going like it should, but I coundn't read them.

Somebody can help me? And yeah, I've used the search enegine of this forum but still found nothing usefull.

Stijnthegamer.
Reply
#51

if I use somethink like this:
pawn Код:
format(sql, sizeof(sql), "SELECT * FROM jobright WHERE userID = '%d' AND jobID = '%d'", GlobalAccountData[playerid][AccountID], JOB_MEDIC);
mysql_query(sql);
mysql_store_result();
if(mysql_num_rows() == 1)
    {
    //do somethink
    }
mysql_free_result();
The server crashes and creates a crashinfo.txt
But when I remove the mysql_free_result(); it just works fine..

Here is the content from the crashinfo.txt:
Код:
--------------------------

Exception At Address: 0x00B56ED0



Registers:

EAX: 0xDDDDDDDD	EBX: 0x00000001	ECX: 0xDDDDDDDD	EDX: 0x00DEFC15

ESI: 0x01215968	EDI: 0x0013F55C	EBP: 0x0013F55C	ESP: 0x0013F520

EFLAGS: 0x00010212



Stack:
Hris
Reply
#52

my problem is done
don't use mysql_debug()
Reply
#53

Could someone who knows please explain what this error means?

Run time error 19: "File or function is not found"

I'm 100% positive I set up the plugin correctly. When I don't include the natives, the plugin loads successfully:
/************************************************/
/* SAMP-MySQL v0.13 Plugin loaded successfully ! */
/************************************************/

Yet when I DO include the natives, I get the runtime error. Which is a piece of crap, by the way, cause the damn thing is very vague and doesn't even give a line number.

Thanks in advance.
Reply
#54

I'm trying to compile the source but MAKE shows these errors... :/

Код:
[root@box source_files]# make
gcc -c -O3 -w -DLINUX -I../SDK/amx/ ../SDK/amx/*.c
g++ -c -O3 -w -DLINUX -I../SDK/amx/ ../SDK/*.cpp
g++ -c -O3 -w -DLINUX -I../SDK/amx/ *.cpp
In file included from main.cpp:3:
main.h:18:26: error: mysql/mysql.h: No such file or directory
source/mysqlhandler.h:16: error: 'my_ulonglong' does not name a type
main.h:38: error: 'MYSQL' does not name a type
main.h:39: error: 'MYSQL_ROW' does not name a type
main.h:40: error: ISO C++ forbids declaration of 'MYSQL_RES' with no type
main.h:40: error: expected ';' before '*' token
main.h:41: error: ISO C++ forbids declaration of 'MYSQL_FIELD' with no type
main.h:41: error: expected ';' before '*' token
make: *** [all] Error 1
Anyone knows wth is this?
Reply
#55

Please post in the correct topic...

You're not in the samp-myql topic but in the alternative mysql plugin topic...

Quote:
Originally Posted by michael2572
Could someone who knows please explain what this error means?

Run time error 19: "File or function is not found"

I'm 100% positive I set up the plugin correctly. When I don't include the natives, the plugin loads successfully:
/************************************************/
/* SAMP-MySQL v0.13 Plugin loaded successfully ! */
/************************************************/

Yet when I DO include the natives, I get the runtime error. Which is a piece of crap, by the way, cause the damn thing is very vague and doesn't even give a line number.

Thanks in advance.
Reply
#56

Good plugin!
I'm doing small functions (i'm beginner) so yeah, would this kinda work:

http://pastebin.com/f2d46eb31

http://pastebin.com/f6b724ec5

Leopard
Reply
#57

Quote:
Originally Posted by simstosh
I'm trying to compile the source but MAKE shows these errors... :/

Код:
[root@box source_files]# make
gcc -c -O3 -w -DLINUX -I../SDK/amx/ ../SDK/amx/*.c
g++ -c -O3 -w -DLINUX -I../SDK/amx/ ../SDK/*.cpp
g++ -c -O3 -w -DLINUX -I../SDK/amx/ *.cpp
In file included from main.cpp:3:
main.h:18:26: error: mysql/mysql.h: No such file or directory
source/mysqlhandler.h:16: error: 'my_ulonglong' does not name a type
main.h:38: error: 'MYSQL' does not name a type
main.h:39: error: 'MYSQL_ROW' does not name a type
main.h:40: error: ISO C++ forbids declaration of 'MYSQL_RES' with no type
main.h:40: error: expected ';' before '*' token
main.h:41: error: ISO C++ forbids declaration of 'MYSQL_FIELD' with no type
main.h:41: error: expected ';' before '*' token
make: *** [all] Error 1
Anyone knows wth is this?
I get that too, I'm a complete noob when it comes to C++!
Reply
#58

Yep same for me, looks like you made a little mistake there G-Styelzzzz :O

Reason I'm recompiling is because the .so file you gave us will crash on mysql_num_rows();

EDIT: To compile make sure you have the file mysql.h
which comes in:
[21:00] <@mabako> rc libmysqlclient15-dev 5.0.32-7etch8 mysql database development files

(apt-get install libmysqlclient15-dev)
Reply
#59

You are awesome, G Stylzz for this one.
Reply
#60

I have a problem . Plugin doesn't work on VPS server WINDOWS SERVER 2003. Plugin by adrenaline work but no have needed functions
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)