TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 01-05-2008, 07:03 PM   #21 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Quote:
Originally Posted by Aaron View Post
If you don't want a user to have the same username as another user you set that as the primary key. There is a fine reason for no auto-increment.
Your primary key should only be a number which exists for the sole purpose of being a constant and unique ID number. What if you want to change names?

Quote:
Originally Posted by Aaron View Post
So... How would I have a value start at one, and go up every time a new user registers?
Set the primary key to auto_incriment, every time you insert a row the ID will go up one. Here is a table I used in a recent project.

[code]
CREATE TABLE `users` (
`id` int(9) NOT NULL auto_increment,
`username` varchar(255) NOT NULL,
`mail` varchar(255) NOT NULL,
`pass` varchar(255) NOT NULL,
`rank` int(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
[/quote]

Create that table in your database and insert a few rows.

Quote:
Originally Posted by Aaron View Post
edit: and why does everyone have this and that as "foo" and "bar" on the explainations? My dad says that all the time and it freaks me out.
Just dummy values, its considered geeky (partially in jest). I just use them because I don't want to spend any time thinking over meaningless values.
__________________

Village Idiot is offline  
Reply With Quote
The Following User Says Thank You to Village Idiot For This Useful Post:
Aaron (01-05-2008)
Old 01-05-2008, 07:08 PM   #22 (permalink)
The Frequenter
 
Join Date: Dec 2007
Location: In my basement
Posts: 386
Thanks: 47
Aaron is on a distinguished road
Default

Actually, SOCK, when I create a table over another table I get an error saying there is already a table.

I also don't see the need for data types that are so peculiar... Saving space really isn't a problem in today's world.

Thank you for your help.

What is this engine=myisam?
wouldn't you want your default charset to be utf-8?
Send a message via MSN to Aaron
Aaron is offline  
Reply With Quote
Old 01-05-2008, 07:13 PM   #23 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Quote:
Originally Posted by Aaron View Post
What is this engine=myisam?
Short version: Internal stuff, complicated. Just use myisam
Long version: The engine is how the database internally stores things. Each MyISAM table is stored on disk in three files. The files have names that begin with the table name and have an extension to indicate the file type. An .frm file stores the table format. The data file has an .MYD (MYData) extension. The index file has an .MYI (MYIndex) extension. For more on the engines, go here MySQL AB :: MySQL 5.0 Reference Manual :: 12 Storage Engines
__________________

Village Idiot is offline  
Reply With Quote
The Following User Says Thank You to Village Idiot For This Useful Post:
Aaron (01-05-2008)
Old 01-05-2008, 08:06 PM   #24 (permalink)
The Acquainted
 
Join Date: Nov 2007
Posts: 154
Thanks: 31
SOCK is on a distinguished road
Default

Quote:
Originally Posted by Aaron View Post
Actually, SOCK, when I create a table over another table I get an error saying there is already a table.
Yes, this is why I suggest using IF NOT EXISTS in your CREATE TABLE statement.

Quote:
Originally Posted by Aaron View Post
I also don't see the need for data types that are so peculiar... Saving space really isn't a problem in today's world.
No offense, but you don't plan on having many records in your database then, or want your application to work efficiently.

Quote:
Originally Posted by Aaron View Post
What is this engine=myisam?
wouldn't you want your default charset to be utf-8?
As VillageIdiot stated, it's the table type, whether InnoDB, MyISAM, HEAP, etc. Used to be MyISAM was the default table type, but has been replaced by InnoDB on most installations. Either one of these will serve you fine, but I prefer to use MyISAM on 'regular' tables I don't need any special constraints on. Thus I specify the table/engine type for each table.

As to the character set, if you want it set to UTF-8, that's fine. Please be aware, the default character set is usually latin1_swedish_ci, even if the server is set to UTF-8.

MySQL Manual : Character set support
SOCK is offline  
Reply With Quote
The Following User Says Thank You to SOCK For This Useful Post:
Aaron (01-05-2008)
Old 05-08-2008, 07:11 PM   #25 (permalink)
The Contributor
 
Join Date: May 2008
Posts: 36
Thanks: 5
Kay1021 is on a distinguished road
Default

Once you select the information from the database.... I get the

SELECT * FROM....


but how do you output that information?
Kay1021 is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 08:57 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design