MySQL - Not setting accounts (Adding)
#1

mysql_register:

Код:
//=====================================
    format(query, sizeof(query), "INSERT INTO playerdata (user, password, bank, money, playerlvl, rpoints, playertime, jail, jailreason, jailtime, banned, banreason");
	format(query, sizeof(query), "whobannedme, whenigotbanned, Skin, ranklvl, rentprice,driverlic, flylic, boatlic, weplic, jobtime, jobskill, totalpayt");
	format(query, sizeof(query), "kills, deaths, housenum, loan, drugs, sdrugs, nreports, power, spawnX, spawnY, spawnZ, spawnZ, spawnInter");
	format(query, sizeof(query), "factnumber, head, headby, famnumber, female, bail, premium, gotphone, phonenumber, phonebook, laptop, virworld, age");
	format(query, sizeof(query), "premiumexpire, playerteam, playerBarrierKeys, radio, freq1, freq2, freq3, tutorial, tbanned, city, married, family");
	format(query, sizeof(query), "faction, PTeamName, job, totalrules, fpay, warns, helper, curfreq, rankname, pdspawn, phonechanges, lastonline)");
	format(query, sizeof(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);
	mysql_debug();
log:

Код:
[05:46:09]  

[05:46:09] ---------------------------

[05:46:09] MySQL Debugging activated (11/05/13)

[05:46:09] ---------------------------

[05:46:09]  

[05:46:09] >> mysql_connect( )

[05:46:09] CMySQLHandler::CMySQLHandler() - constructor called.

REMOVED FOR  SECURITY

[05:46:09] CMySQLHandler::Connect() - Connection was successful.

[05:46:09] CMySQLHandler::Connect() - Auto-Reconnect has been enabled.

[05:46:14]  

[05:46:14] ---------------------------

[05:46:14] MySQL Debugging activated (11/05/13)

[05:46:14] ---------------------------

[05:46:14]  

[05:46:43] >> mysql_query( Connection handle: 1 )

[05:46:43] CMySQLHandler::Query(SELECT IP FROM `playerdata` WHERE user = 'Brandon_Harrison' LIMIT 1) - Successfully executed.

[05:46:43] >> mysql_store_result( Connection handle: 1 )

[05:46:43] CMySQLHandler::StoreResult() - Result was stored.

[05:46:43] >> mysql_num_rows( Connection handle: 1 )

[05:46:43] CMySQLHandler::NumRows() - Returned 0 row(s)

[05:46:43] >> mysql_free_result( Connection handle: 1 )

[05:46:43] CMySQLHandler::FreeResult() - Result was successfully free'd.

[05:46:47] >> mysql_real_escape_string( Connection handle: 1 )

[05:46:47] CMySQLHandler::EscapeString(159159); - Escaped 6 characters to 159159.

[05:46:47] >> mysql_query( Connection handle: 1 )

[05:46:47] CMySQLHandler::Query(VALUES ('Brandon_Harrison', SHA1('159159'), 0, 10000, 1, 0, 0, 0, ('Not Jailed', 0, 0, 'Not Banned', 'NoBodY', 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, 'NoBodY', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'NoBodY', 'San Fierro', 'NoBodY', 'No Family','No Faction', 'No Team', 0, 0)) - An error has occured. (Error ID: 1064, You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'VALUES ('Brandon_Harrison', SHA1('159159'), 0, 10000, 1, 0, 0, 0, ('Not Jailed',' at line 1)

[05:46:48] >> mysql_query( Connection handle: 1 )

[05:46:48] CMySQLHandler::Query(job='', totalruns=0, fpay=0, warns=0, helper=0, curfreq=0, rankname='', pdspawn=0, phonechanges=0, lastonline=0 WHERE user='') - An error has occured. (Error ID: 1064, You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'job='', totalruns=0, fpay=0, warns=0, helper=0, curfreq=0, rankname='', pdspawn=' at line 1)
Reply
#2

First of all you formatted the string many times which caused the system to store the last formatted value in the string i.e. "INSERT ...." You need to make only one query.. use strcat to join 2 strings
Reply
#3

Or if you wanted to use format here is the proper way:
Use the "\" It will be way more useful!

Like this:

pawn Код:
format(query, sizeof(query), "INSERT INTO playerdata (user, password, bank, money, playerlvl, rpoints, playertime, jail, jailreason, jailtime, banned, banreason\
    whobannedme, whenigotbanned, Skin, ranklvl, rentprice,driverlic, flylic, boatlic, weplic, jobtime, jobskill, totalpayt,\
kills, deaths, housenum, loan, drugs, sdrugs, nreports, power, spawnX, spawnY, spawnZ, spawnZ, spawnInter,\
factnumber, head, headby, famnumber, female, bail, premium, gotphone, phonenumber, phonebook, laptop, virworld, age,\
premiumexpire, playerteam, playerBarrierKeys, radio, freq1, freq2, freq3, tutorial, tbanned, city, married, family,\
faction, PTeamName, job, totalrules, fpay, warns, helper, curfreq, rankname, pdspawn, phonechanges, lastonline,\
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)