Saving a string to MySQL
#1

Код:
SaveSQLStr(HouseData[houseid][HouseID], "houses", "OwnerName", HouseData[houseid][HouseOwnerName]);
I use this line of code to save the owners name to MySQL.

Here's my SaveSQLStr :

Код:
Server:SaveSQLStr(sqlid, table[], row[], value)
{
	new query[500];
	mysql_format(sqlBaglanti, query, sizeof query, "UPDATE %e SET %e = '%s' WHERE id = '%i'", table, row, value, sqlid);
	mysql_pquery(sqlBaglanti, query);
	return true;
}
But strangely it adds another letter to the name.

For example, if the owners name is "Harold Kingston". It saves it like this: "HHarold Kingston". I couldn't figure out what is wrong.
Reply
#2

How is this not giving you any errors or warnings while compiling? And if it does, why are you ignoring them? The "value" parameter should be declared as an array but it is not.

Also I hope you don't have 20 of those "SaveSQL_" statements beneath each other because that would be very inefficient.
Reply
#3

Another thing, you ironically escape everything but the value you're setting, which is likely to at times be user input (password, etc). Change %s to %e, seriously.
Reply
#4

Quote:
Originally Posted by Vince
Посмотреть сообщение
How is this not giving you any errors or warnings while compiling? And if it does, why are you ignoring them? The "value" parameter should be declared as an array but it is not.

Also I hope you don't have 20 of those "SaveSQL_" statements beneath each other because that would be very inefficient.
Well i get no errors or warnings while compiling. I updated the value parameter to an array. Didn't work. No worries i don't have it like that.

Quote:
Originally Posted by Abagail
Посмотреть сообщение
Another thing, you ironically escape everything but the value you're setting, which is likely to at times be user input (password, etc). Change %s to %e, seriously.
Changed it still not working.
Reply
#5

Add a print statement with the query string.
Reply
#6

Код:
SaveSQLStr(HouseData[houseid][HouseID], "houses", "OwnerName", HouseData[houseid][HouseOwnerName]);

Server:SaveSQLStr(sqlid, table[], row[], value)
{
	new query[500];
	mysql_format(sqlBaglanti, query, sizeof query, "UPDATE %e SET %e = '%s' WHERE id = '%i'", table, row, value, sqlid);
	mysql_pquery(sqlBaglanti, query);
	return true;
}

'value' is not a type string

And replace with:

SaveSQLStr(HouseData[houseid][HouseID], "houses", "OwnerName", houseid);

Server:SaveSQLStr(sqlid, table[], row[], value)
{
	new query[500];
	mysql_format(sqlBaglanti, query, sizeof query, "UPDATE `%s` SET `%s` = '%s' WHERE `id` = '%d'", table, row, value, sqlid);
	mysql_tquery(sqlBaglanti, query, "", "");
	return true;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)