Mysql creating tables
#1

Hello,
This is my first time as i create tables and use mysql , i made this but have some errors

and i get this error
Код:
 #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 '(11) NOT NULL, `pLastOn` TIMESTAMP(11) NOT NULL, `pHealth` FLOAT(11) NOT NULL, `' at line 1
Reply
#2

You get this on the phpmyadmin page or on the Debug.txt file?
If it's on the Debug.txt file, post the code.
Reply
#3

Its on the phpmyadmin page
Reply
#4

The floats don't need values, AFAIK.. I'm really no expert with SQL but try removing the values from all the Floats. Same with timestamps - I really don't think they need length/values, so if the problem still occurs, try removing the values from them too.

Disclaimer: I have just started to (try) using MySQL to store user data myself, so I have really no idea what causes this error
Reply
#5

That worked, thnaks larzi.
I made this but its still not showing the dialogs
pawn Код:
new rows = mysql_num_rows(); //We get how many rows the query returned.
    if(!rows)
    {
    ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""#COL_EMB_WHITE"Account Registration", ""#COL_EMB_WHITE"This account has "#COL_EMB_RED"not been registered"#COL_EMB_WHITE"!\n\nEnter your desired password below to register this account.", "Submit", "Leave");
    }
    if(rows == 1)
    {
    ShowPlayerDialog(playerid, DIALOG_AUTHENTICATION, DIALOG_STYLE_PASSWORD, ""#COL_EMB_WHITE"Account Authentication", ""#COL_EMB_WHITE"This account has "#COL_EMB_GREEN"been registered"#COL_EMB_WHITE"!\n\nEnter the account password below to proceed.", "Submit", "Leave");
    }
Reply
#6

Quote:
Originally Posted by MadafakaPro
Посмотреть сообщение
That worked, thnaks larzi.
Like I suspected - no problem.

Quote:
Originally Posted by MadafakaPro
Посмотреть сообщение
I made this but its still not showing the dialogs
pawn Код:
new rows = mysql_num_rows(); //We get how many rows the query returned.
    if(!rows)
    {
    ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""#COL_EMB_WHITE"Account Registration", ""#COL_EMB_WHITE"This account has "#COL_EMB_RED"not been registered"#COL_EMB_WHITE"!\n\nEnter your desired password below to register this account.", "Submit", "Leave");
    }
    if(rows == 1)
    {
    ShowPlayerDialog(playerid, DIALOG_AUTHENTICATION, DIALOG_STYLE_PASSWORD, ""#COL_EMB_WHITE"Account Authentication", ""#COL_EMB_WHITE"This account has "#COL_EMB_GREEN"been registered"#COL_EMB_WHITE"!\n\nEnter the account password below to proceed.", "Submit", "Leave");
    }
Where'd you put that? Inside OnQueryFinish? (presuming you're using R6)
Reply
#7

I am using R7 and i added this on OnPlayerConnect
Reply
#8

If you're already using threaded queries (which is the only type R7 supports) I recommend updating to R15 as it adds a couple of extra features and fixed some bugs.

/rant

Now ontopic: You're using mysql_num_rows inside OnPlayerConnect. mysql_num_rows retrieves the number of rows from a result set after sending a SELECT or SHOW query. You'll need to send a SELECT query to check for the player in the table, then in the callback (which you specify) you can use cache_get_data to retrieve the data and check for rows.

https://sampforum.blast.hk/showthread.php?tid=390428 Here's an example gamemode using this method. I recommend reading it - it helped me a lot!

Summary:

Send a SELECT query in OnPlayerConnect:

pawn Код:
new
    szQuery[ 90 ]
;
format( szQuery, sizeof( szQuery ), "SELECT * from `your_table_here` WHERE `name` = '%s' LIMIT 1", Name( playerid ));
mysql_function_query( handle, szQuery, true, "OnUserCheck", "i", playerid );
Check rows in the specified callback (OnUserCheck):

pawn Код:
forward OnUserCheck(playerid);
public OnUserCheck(playerid)
{
    new
        rows,
        fields
    ;
    cache_get_data( rows, fields, handle );
    if( rows )
    {
        // exists - player should log in
    }
    else
    {
        // doesn't exist - player should register
    }
    return true;
}
And that's about it. Keep in mind that this is just a very very rough example.

You should read this tutorial: https://sampforum.blast.hk/showthread.php?tid=337810 on using cache in R7 and newer
Reply
#9

I love when people pull lines from my released GM's and say: "I made this, but..."

Why are you modifying the code from my GM? It worked perfectly where it was...
Reply
#10

@RealCop228 Its not working i tryed to enter IG a\but the dialog didnt show up
And i didnt sayd i made the script i sayd i made the tables...

@Larzi
I didnt tryed that i will try tommorow and tell u if it works.. Thanks anyways.

And here is what i did..
: http://pastebin.com/EXjcKdjs
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)