Mysql problem
#1

Hi,

I have a problem with something I founded in a tutorial,


I got those errors:

test2.pwn(251) : error 017: undefined symbol "GetPName"
test2.pwn(253) : error 035: argument type mismatch (argument 2)


Line 251:
format(Query,sizeof(Query),"INSERT INTO `Users` (Username,Password,Argent) VALUES ('%s','%s,'0')",GetPName(playerid),EscapedText);



Line 253:
253: SendClientMessage(playerid,green,"You have been successfully registered!");



Could you please help me ?

Thank you
Reply
#2

PHP код:
format(Query,sizeof(Query),"INSERT INTO `Users` (Username,Password,Argent) VALUES ('%s','%s,'0')",GetPlayerName(playerid),EscapedText); 
Show 'green'
Reply
#3

green: #define green "{008000}"


EDIT: I changed it to
#define green 0x9EC73DAA

Now I got no problems with this.

But I still have the other error


test2.pwn(251) : error 017: undefined symbol "GetPName"






And if I use your " format(Query,sizeof(Query),"INSERT INTO `Users` (Username,Password,Argent) VALUES ('%s','%s,'0')",GetPlayerName(playerid),EscapedTex t);"



I got two warnings:

test2.pwn(251) : warning 202: number of arguments does not match definition
test2.pwn(251) : warning 202: number of arguments does not match definition
Reply
#4

It's wrong. SCM uses hexidecimal colours,

#define green 0x9BFF00FF
Reply
#5

#define green 0x008000FF

//Edit: Show all code near...
Reply
#6

It's from a mysql tutorial:


Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	if(dialogid == 1)
	{
		if(strlen(inputtext) == 0)
		{
			ShowPlayerDialog(playerid,Regdialog,DIALOG_STYLE_INPUT,"Register - Enter your password","You are about to register a new account! \nPlease choose the password"" for it! \n","Register!","");
		}
		else
		{
			new Query[256];
			new EscapedText[60];
			mysql_real_escape_string(inputtext, EscapedText);
			format(Query,sizeof(Query),"INSERT INTO `Users` (Username,Password,Argent) VALUES ('%s','%s,'0')",GetPlayerName(playerid),EscapedText);
			mysql_query(Query);
			SendClientMessage(playerid,green,"You have been successfully registered!");
			GivePlayerMoney(playerid,5000);
			SetPlayerScore(playerid,1);
		}
	}
	

	return 1;
}
Reply
#7

Where did you define GetPName?

Also. HardRock your "GetPlayerName" is totally wrong.

The correct syntax for it is:
GetPlayerName(playerid, const name[], len);
Reply
#8

Try this stock function though:

pawn Код:
stock GetPName(playerid)
    {
        new p[24];
        GetPlayerName(playerid, p, sizeof(p));
        return p;
    }
Try that
Reply
#9

So what should I use instead of " format(Query,sizeof(Query),"INSERT INTO `Users` (Username,Password,Argent) VALUES ('%s','%s,'0')",GetPlayerName(playerid),EscapedTex t);"

?

I'm sorry but I am a beginner so, how should I define GetPName ?

I tried to follow this tutorial: https://sampforum.blast.hk/showthread.php?tid=305994

But even in the tutorial, they were errors.
Reply
#10

This is the total code I got

Maybe it will help more

http://pastebin.com/0859GhJg
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)