• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Znote_accounts add table

Jfrye

Mapper, trying to learn scripting
Joined
Jan 8, 2009
Messages
366
Solutions
5
Reaction score
86
Location
Mexico Missouri
I was wandering if anyone could tell me how to add a table to znote_accounts called owner name or player name.

Just wanting to add a small little personal preference to the layout.

I think it goes something like this, but Im honestly not sure as Im still trying to learn all this stuff.

Code:
ALTER TABLE `znote_accounts` ADD `player_name`

EDIT : Im using Znote 1.5
EDIT 2 : Im trying to add a more personal touch to the myaccounts.php page. So if I can add this table to the database, will it read a normal name? like player name= Justin
 
Solution
In the database, you can do this query to add a text field to the znote_accounts row:
SQL:
ALTER TABLE `znote_accounts` ADD `player_name` VARCHAR(30) NOT NULL DEFAULT '' AFTER `flag`;
You can set varchar(30) to (20) or something else to allow players to use more or less characters in their name.

Database structure done.

Then we need to tell Znote AAC to load this resource from db:
ZnoteAAC/init.php at master · Znote/ZnoteAAC · GitHub
PHP:
$user_znote_data = user_znote_account_data($session_user_id, 'ip', 'created', 'points', 'cooldown', 'flag', 'player_name');
(add , 'player_name' to the end of the function param of user_znote_account_data).

Var loading from DB done.

($user_data contains current loggedin info from the...
Thank you @Znote, but there seems to be an issue that it will only work for 1 account. I have 2 accounts to test this with, and only 1 of them will work. The one that works is correct though.

I have tried clearing the cache on chrome, and also tried to view this from another device, and the 1 account still doesnt work.

EDIT, my database is a little screwed up. My accounts arent matching up between accounts and znote_accounts. So it is working. I just need to clear my database and start over.

EDIT 2 : I tried to Empty the table (TRUNCATE) so I can reset all the account information for both accounts and znote_accounts, and when I do I get this error.

Code:
UPDATE `otserv`.`accounts` SET `id` = '1' WHERE `accounts`.`id` = 2



MySQL said: [IMG]http://localhost/us_opt1/themes/dot.gif[/IMG]

#1451 - Cannot delete or update a parent row: a foreign key constraint fails (`otserv`.`account_viplist`, CONSTRAINT `account_viplist_ibfk_1` FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) ON DELETE CASCADE)

Is there an easier way to just reset the whole database without deleting any tables?
 
Last edited:
Thank you @Znote, but there seems to be an issue that it will only work for 1 account. I have 2 accounts to test this with, and only 1 of them will work. The one that works is correct though.

I have tried clearing the cache on chrome, and also tried to view this from another device, and the 1 account still doesnt work.

EDIT, my database is a little screwed up. My accounts arent matching up between accounts and znote_accounts. So it is working. I just need to clear my database and start over.

EDIT 2 : I tried to Empty the table (TRUNCATE) so I can reset all the account information for both accounts and znote_accounts, and when I do I get this error.

Code:
UPDATE `otserv`.`accounts` SET `id` = '1' WHERE `accounts`.`id` = 2



MySQL said: [IMG]http://localhost/us_opt1/themes/dot.gif[/IMG]

#1451 - Cannot delete or update a parent row: a foreign key constraint fails (`otserv`.`account_viplist`, CONSTRAINT `account_viplist_ibfk_1` FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) ON DELETE CASCADE)

Is there an easier way to just reset the whole database without deleting any tables?

You need to truncate the tables that rely on accounts table before truncating the actual accounts table.
This should work on all accounts that have the column account_id in znote_accounts table linked up against the id column of the accounts table. (znote_accounts.account_id -> accounts.id). Meaning that the account is Znote AAC compatible.

You may also need to fix the compatibility script that makes sure old accounts are converted to work with Znote AAC:
ZnoteAAC/database2znoteaac.php at master · Znote/ZnoteAAC · GitHub
Change:
PHP:
mysql_insert("INSERT INTO `znote_accounts` (`account_id`, `ip`, `created`, `flag`) VALUES ('$old', '0', '$time', '')");
With:
PHP:
mysql_insert("INSERT INTO `znote_accounts` (`account_id`, `ip`, `created`, `flag`, `player_name`) VALUES ('$old', '0', '$time', '', 'Anonymous')");
 
Last edited:
Im having problems with the normal accounts table

I get this error
Code:
[IMG]http://localhost/us_opt1/themes/dot.gif[/IMG] #1701 - Cannot truncate a table referenced in a foreign key constraint (`otserv`.`account_bans`, CONSTRAINT `account_bans_ibfk_1` FOREIGN KEY (`account_id`) REFERENCES `otserv`.`accounts` (`id`))

I have cleared every table in the db
 
Im having problems with the normal accounts table

I get this error
Code:
[IMG]http://localhost/us_opt1/themes/dot.gif[/IMG] #1701 - Cannot truncate a table referenced in a foreign key constraint (`otserv`.`account_bans`, CONSTRAINT `account_bans_ibfk_1` FOREIGN KEY (`account_id`) REFERENCES `otserv`.`accounts` (`id`))

I have cleared every table in the db
You cannot do that because the account_bans table foreign key requires a connection to accounts.id
 
Back
Top