MySQL Headaches

Discussion in 'Plugin Development' started by x128, Oct 2, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    x128

    Hi Everyone,
    I've been having so much trouble with MySQL in my plugins. I can connect to my database and execute statements no problem. The issue I am having is that I can not figure out how to use MySQL statements at all. Previously, I have been using Vault to hook into a MySQL economy plugin, but that had issues that I did not want, and just thought it would be more efficient to hard code MySQL support into my plugin instead.

    A few questions I have, but could not figure out.
    - How do I create a new table inside my Database to store player tokens (String, int)?
    - How would I add/remove tokens from a player's balance?
    - How would I check if the player has a line in my table, and create one if they don't?

    Thank you very much!
     
  2. Offline

    chasechocolate

    Are you asking for help on integrating it into your plugin or the MySQL syntax? If syntax, then just google "mysql <question>". E.g. "mysql create table", "mysql add row", "mysql check if table contains".
     
  3. Offline

    x128

    Just tried to make a table by SSHing to my dedicated server and going into the MySQL command window. I've tried to use a tutorial, but it won't make my table. Any suggestions?

    Code:
    mysql> CREATE TABLE tokens(
        -> player VARCHAR(100) NOT NULL,
        -> tokens INT NOT NULL
        -> PRIMARY KEY ( player )
        -> );
    ERROR 1064 (42000): 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 '( player )
    )' at line 4
    mysql> 
     
  4. Offline

    chasechocolate

    x128 I don't know much MySQL myself, but I think you are missing a comma after "tokens INT NOT NULL".
     
Thread Status:
Not open for further replies.

Share This Page