![]() |
Is this a good query?
PHP Code:
|
Well.. that depends on what you're building. If for this system you need only the user's name and password then it's ok.
About the password, how do you plan to store them? If you're gonna store flat passwords (kinda insecure) 30 characters are ok, but if you're going to store the md5 hash you're gonna need 32 chars. For a sha-1 hash you need 40 chars. |
I agree with DeMo, you need to consider the `password` field and how it relates to what hash you're storing there.
In addition, make sure you add a UNIQUE index on the `name` field. SMALLINT is probably enough for your application, but using INT isn't going to hurt anything. |
Thanks for your help. I didn't think that more than 4 people would have an account on this, so I just made it a smallint.
|
Good call on the ALTER statement to create a UNIQUE index. In cases like this where you want to avoid users having the same username, the easiest way to implement it (and have the benefits of using an index) is with UNIQUE.
Quote:
Well, that will certainly hold 4 accounts. :-D TINYINT (unsigned) is up to 255. SMALLINT (unsigned) will run up to 65,535. INT (unsigned) is up to 4,294,967,295 (yes, that's trillion). In your case, especially for test tables or small user groups, TINYINT(2) UNSIGNED (to 99) will usually suffice. Just one byte per value. MySQL Manual : Data Types | Numeric types |
Quote:
TINYINT(2) UNSIGNED still has the normal range of values (0-255) of plain jane TINYINT UNSIGNED. The (2) is only a padding value if the column is declared with ZEROFILL.To put clearer, if you try to insert a value of 100 into a TINYINT(2) column then it'll work fine. If you try to insert 256, then MySQL will throw back a warning "Out of range value adjusted for column 'id' at row 1" and adjust the value to 255. |
salathe> Thanks for the clarification. I guess I should read the links I post completely, eh?
|
Why doesn't this work?
PHP Code:
|
Your SQL isn't wrapped in string delimiters (single quotes).
|
Okay...
How do I connect to the database when my username doesn't have a password? |
Just use "" in place of the password in mysql_connect()
Alan |
| All times are GMT. The time now is 09:01 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0