mySQL safe problem
#1

Ok this is really weird.

As soon as I use this:
Код:
format(Query, sizeof(Query), "INSERT INTO `houses` (houseID, HouseOwner, hX, hY, hZ) VALUES ('%d', '%s', %f, %f, %f)", random(250), pName(playerid), X, Y, Z);
It works fine and a new file gets created in the mySQL database with another house.

But as soon as I had this:
Код:
format(Query, sizeof(Query), "INSERT INTO `houses` (houseID, HouseOwner, hX, hY, hZ, Virtualworld, Interior) VALUES ('%d', '%s', %f, %f, %f, %d, %d)", random(250), pName(playerid), X, Y, Z, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid));
The virtualworld and playerinterior... it doesn't safe a file, Someone can tell me why?
Reply
#2

Hmm, Maybe try this?

pawn Код:
format(Query, sizeof(Query), "INSERT INTO `houses` (houseID, HouseOwner, hX, hY, hZ, Virtualworld, Interior) VALUES (%d, '%s', %f, %f, %f, %d, %d)", random(250), pName(playerid), X, Y, Z, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid));
I am a noob at Sql xD
Reply
#3

Unfortunately it didn't work.

but yeah it makes sort of sense.
Код:
'whatever here'
Is only for things like:
Код:
new something[256];
right?
Reply
#4

What is the size of Query? Maybe it's too small for everything to fit in.
Reply
#5

Thanks Steve! Man.. I'm stupid. But I thought if it was the size, I would get a warning or error message (didn't get any), Still your solution fixed my stupid problem, Thanks!
Reply
#6

Unfortunately not, the data that is sent to be written is merely cut from the format.
Reply
#7

Quote:
Originally Posted by jesse237
Посмотреть сообщение
Thanks Steve! Man.. I'm stupid. But I thought if it was the size, I would get a warning or error message (didn't get any), Still your solution fixed my stupid problem, Thanks!
No problem, man! Any time
Reply
#8

Ok I'm having a similar problem now, except this time It is now the size of the Query array...

This works fine, a new file in the mysql database gets created:
Код:
stock SaveHouses(playerid, PHouseID, PHouseOwner[], Float:PX, Float:PY, Float:PZ, Virtual, Interior, HCost, HInt, HAdress[])
{
	new
	    aa = Virtual,
		ab =  Interior,
		bb = HCost,
		bc = HInt,
		cc = HAdress[256],
		Query[1024];
		//Query2[600];
		
	format(Query, sizeof(Query), "INSERT INTO `houses` (houseID, HouseOwner, hX, hY, hZ, Virtualworld, Interior) VALUES (%d, '%s', %f, %f, %f, %d, %d)",
	PHouseID, PHouseOwner, PX, PY, PZ, aa, ab);
	mysql_query(Query);
	//mysql_query(Query2);
	mysql_free_result();
	return 1;
}
And this doesn't work, while just one thing is added to the list of the format function, but no new files get created in the mysql database, all because of one extra thing.
Код:
stock SaveHouses(playerid, PHouseID, PHouseOwner[], Float:PX, Float:PY, Float:PZ, Virtual, Interior, HCost, HInt, HAdress[])
{
	new
	    aa = Virtual,
		ab =  Interior,
		bb = HCost,
		bc = HInt,
		cc = HAdress[256],
		Query[1024];
		//Query2[600];
		
	format(Query, sizeof(Query), "INSERT INTO `houses` (houseID, HouseOwner, hX, hY, hZ, Virtualworld, Interior, Cost) VALUES (%d, '%s', %f, %f, %f, %d, %d, %d)",
	PHouseID, PHouseOwner, PX, PY, PZ, aa, ab, bb);
	mysql_query(Query);
	//mysql_query(Query2);
	mysql_free_result();
	return 1;
}
Btw, can someone inform me about string sizes, because I read different things, like somewhere it said, the maximum could be 256, somewhere else it said it doesn't matter and the mysql gamemode from [leth4l] says Query[600], So I'm not sure what the maximum is.
Reply
#9

You've got a '%d' too much: You want to update 7 fields but are inputting 8 variables.
Reply
#10

No wait, I f*cked up on my post, that isn't my original code, I'll edit it.

EDIT: Ok, I edited the post. Sorry for the mistake.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)