Strings in strcat - MySQL
#1

Sorry that I have been needing help with soo much stuff for the past few days.. been trying to convert a full script to MySQL with no understanding of it :/ Retarded I know.. but been stuck on this for ages! Can someone give me some help.. <3

I will upload the full function..

Код:
stock MySQL_Register(playerid, passwordstring[])
{
    new query[ 3584 ], pname[24];
//=============================[String Variable defines]
	new jailr[20], banr[20], whobanedme[25], whenigotbaned[25], Headby[25], City[20], Married[25], Family[20], Faction[20], PteamName[10],
	Job[10], Rankname[17];
	format(jailr, 20, "Not Jailed");
	format(banr, 20, "Not Banned");
	format(whobanedme, 25, "NoBodY");
	format(whenigotbaned, 25, "NoBodY");
	format(Headby, 25, "NoBodY");
	format(City, 20, "San Fierro");
	format(Married, 25, "NoBodY");
	format(Family, 20, "No Family");
	format(Faction, 20, "No Faction");
	format(PteamName, 10, "No Team");
	format(Job, 10, "No Job");
	format(Rankname, 17, "No Rank");
    GetPlayerName(playerid, pname, 24);
//=====================================
 	strcat(query, "INSERT INTO playerdata(user, password, bank, money, playerlvl, rpoints, playertime, jail, jailreason, jailtime, banned, banreason,");
	strcat(query, "whobannedme, whenigotbanned, Skin, ranklvl, rentprice,driverlic, flylic, boatlic, weplic, jobtime, jobskill, totalpayt,");
	strcat(query, "kills, deaths, housenum, loan, drugs, sdrugs, nreports, power, spawnX, spawnY, spawnZ, spawnZ, spawnInter,");
	strcat(query, "premiumexpire, playerteam, playerBarrierKeys, radio, freq1, freq2, freq3, tutorial, tbanned, city, married, family,");
	strcat(query, "faction, PTeamName, job, totalrules, fpay, warns, helper, curfreq, rankname, pdspawn, phonechanges, lastonline)");
	strcat(query, " VALUES ('%s', SHA1('%s'), 0, 10000, 1, 0, 0, 0, '%s', 0, 0, '%s', '%s', 7, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, '%s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '%s', '%s', '%s', '%s', '%s', '%s', 0, 0 )", pname, passwordstring, jailr, banr, whobanedme, whenigotbaned, Headby, City, Married, Family, Faction, PteamName, Job, Rankname);
//=====================================
	mysql_query(query);
    SendClientInfo(playerid, "Congradulations, you have now registed. You will be spawned at SF train Station");
    PLAYERLIST_authed[playerid]=true;
    return 1;
}
Код:
: error 035: argument type mismatch (argument 3)
Reply
#2

Line ? and use default text / value in your database structure !
Reply
#3

Try'd this and it compiled allright

Код:
stock MySQL_Register(playerid, passwordstring[])
{
    new query[ 3584 ], query2[ 4584 ], query3[ 4584 ], pname[24];
//=============================[String Variable defines]
	new jailr[20], banr[20], whobanedme[25], whenigotbaned[25], Headby[25], City[20], Married[25], Family[20], Faction[20], PteamName[10],
	Job[10], Rankname[17];
	format(jailr, 20, "Not Jailed");
	format(banr, 20, "Not Banned");
	format(whobanedme, 25, "NoBodY");
	format(whenigotbaned, 25, "NoBodY");
	format(Headby, 25, "NoBodY");
	format(City, 20, "San Fierro");
	format(Married, 25, "NoBodY");
	format(Family, 20, "No Family");
	format(Faction, 20, "No Faction");
	format(PteamName, 10, "No Team");
	format(Job, 10, "No Job");
	format(Rankname, 17, "No Rank");
    GetPlayerName(playerid, pname, 24);
//=====================================
 	strcat(query2, "INSERT INTO playerdata(user, password, bank, money, playerlvl, rpoints, playertime, jail, jailreason, jailtime, banned, banreason,");
	strcat(query2, "whobannedme, whenigotbanned, Skin, ranklvl, rentprice,driverlic, flylic, boatlic, weplic, jobtime, jobskill, totalpayt,");
	strcat(query2, "kills, deaths, housenum, loan, drugs, sdrugs, nreports, power, spawnX, spawnY, spawnZ, spawnZ, spawnInter,");
	strcat(query2, "premiumexpire, playerteam, playerBarrierKeys, radio, freq1, freq2, freq3, tutorial, tbanned, city, married, family,");
	strcat(query2, "faction, PTeamName, job, totalrules, fpay, warns, helper, curfreq, rankname, pdspawn, phonechanges, lastonline)");
	strcat(query2, " VALUES ");
//=================================
	format(query3, sizeof(query3), "('%s', SHA1('%s'), 0, 10000, 1, 0, 0, 0, '%s', 0, 0, '%s', '%s', 7, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, '%s', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '%s', '%s', '%s', '%s', '%s', '%s', 0, 0 )", pname, passwordstring, jailr, banr, whobanedme, whenigotbaned, Headby, City, Married, Family, Faction, PteamName, Job, Rankname);
//=================================
	format(query, sizeof(query), query2, query3);
//=====================================
	mysql_query(query);
    SendClientInfo(playerid, "Congradulations, you have now registed. You will now be spawned at SF train Station");
    PLAYERLIST_authed[playerid]=true;
    return 1;
}
Will this work or will it cause bugs & Leap holes?
Reply
#4

show table structure, too many huge arrays possilby crash code
Reply
#5

Код:
	mysql_query("CREATE TABLE IF NOT EXISTS playerdata( user VARCHAR(24), password VARCHAR(40), bank INT(20), playerlvl INT(20), rpoints INT(20), playertime INT(20), jail INT(20), jailreason VARCHAR(24), jailtime INT(20), banned INT(20), banreason VARCHAR(24), whobannedme VARCHAR(24), whenigotbanned VARCHAR(24), Skin INT(20), ranklvl INT(20), rentprice INT(20), driverlic INT(20), flylic INT(20) )");
 	mysql_query("ALTER TABLE playerdata ADD boatlic INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD weaplic INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD jobtime INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD jobskill INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD totalpayt INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD kills INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD deaths INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD housenum INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD loan INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD drugs INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD guns INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD sguns INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD sdrugs INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD power INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD spawnX INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD spawnY INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD spawnZ INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD spawnInter INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD factnumber INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD head INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD headby VARCHAR(20)");
 	mysql_query("ALTER TABLE playerdata ADD famnumber INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD female INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD bail INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD premium INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD gotphone INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD phonenumber INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD phonebook INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD laptop INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD virworld INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD age INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD premiumexpire INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD playerteam INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD playerBarrierKeys INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD radio INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD freq1 INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD freq2 INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD freq3 INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD tutorial INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD tbanned INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD city VARCHAR(20)");
 	mysql_query("ALTER TABLE playerdata ADD married VARCHAR(20)");
 	mysql_query("ALTER TABLE playerdata ADD family VARCHAR(20)");
 	mysql_query("ALTER TABLE playerdata ADD faction VARCHAR(20)");
 	mysql_query("ALTER TABLE playerdata ADD PTeamName VARCHAR(20)");
 	mysql_query("ALTER TABLE playerdata ADD job VARCHAR(20)");
 	mysql_query("ALTER TABLE playerdata ADD totalruns INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD fpay INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD warns INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD helper INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD curfreq INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD rankname VARCHAR(20)");
 	mysql_query("ALTER TABLE playerdata ADD pdspawn INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD phonechanges INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD lastonline INT(20)");
 	mysql_query("ALTER TABLE playerdata ADD IP varchar(15)");
Reply
#6

Look how to use DEFAULT and complete the rest of the table

pawn Код:
mysql_query("CREATE TABLE IF NOT EXISTS playerdata (\
user VARCHAR(24) NOT NULL,\
password VARCHAR(40) NOT NULL,\
bank INT(10) UNSIGNED NOT NULL DEFAULT 0,\
money INT(10) NOT NULL DEFAULT 10000,\
playerlvl SMALLINT(5) UNSIGNED NOT NULL DEFAULT 1,\
rpoints SMALLINT(5) UNSIGNED NOT NULL DEFAULT 0,\
playertime INT(10) UNSIGNED NOT NULL DEFAULT 0,\
jail SMALLINT(5) UNSIGNED NOT NULL DEFAULT 0,\
jailreason VARCHAR(24) NOT NULL DEFAULT 'Not Jailed',\
jailtime SMALLINT(5) UNSIGNED NOT NULL DEFAULT 0,\
banned SMALLINT(5) UNSIGNED NOT NULL DEFAULT 0,\
banreason VARCHAR(24) NOT NULL DEFAULT 'Not Banned',\
whobannedme VARCHAR(24) NOT NULL DEFAULT 'NoBodY',\
whenigotbanned VARCHAR(24) NOT NULL DEFAULT 'NoBodY',\
Skin SMALLINT(3) UNSIGNED NOT NULL DEFAULT 7,\
ranklvl SMALLINT(5) UNSIGNED NOT NULL DEFAULT 0,\
rentprice INT(20),\
driverlic INT(20),\
flylic INT(20) )"
);
then you can use only

pawn Код:
MySQL_Register(playerid, passwordstring[])
{
    new query[ 150 ], pname[MAX_PLAYER_NAME + 1];
    GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
    format(query,sizeof(query),"INSERT INTO playerdata (user, password) VALUES ('%s', SHA1('%s'));",pname, passwordstring);
    mysql_query(query);
    SendClientInfo(playerid, "Congradulations, you have now registed. You will be spawned at SF train Station");
    PLAYERLIST_authed[playerid] = true;
    return;
}
looks better ?

remember if you need only small numbers don't use INT()
here for example
pawn Код:
rentprice INT(20),\
driverlic INT(20),\
flylic INT(20) )");
read about data types

http://www.w3schools.com/sql/sql_datatypes.asp
Reply
#7

Thanks man, edited nearly everything I need to.. show you how it goes in the next few hours.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)