View Full Version : Question About Column

04-06-2007, 12:55 PM
I am going to import about 200 generated codes into a MySQL table... Just had a queation, the codes will look like this as an e.g. 7dYhsj8. So would I just make then 'Text' as the data type and Not Null?

04-06-2007, 01:16 PM
Don't use TEXT, use VARCHAR(7) or bigger, to the maximum possible size of the code.

04-06-2007, 01:24 PM
Twey are you familiar at all with phpMyAdmin? Attached is a snap shot of my table columns... It has alot of other options which I am not sure about... I made the id the primary key, do i need to make the code column a unique key?

04-06-2007, 02:18 PM
Somewhat, but not very. I prefer the command-line client.

If the code is going to be unique, you might as well use that as the primary key and scrap the ID column.

04-06-2007, 02:42 PM
ID columns often confuse me though, because if I delete a record, it will skip the ID. Example 1, 2, 3, (deleted), 5, 6, 7.
So if I use a loop that method of obtaining the data won't work. Instead I use mysql_fetch_assoc().

As for the data type, I wouldn't use TEXT if it's only about 10 characters long, as Twey stated varchar would be better.

04-06-2007, 05:10 PM
mysql_fetch_row() and mysql_fetch_assoc() are now both redundant... you should use mysql_fetch_array() instead (a second argument can be passed, MYSQL_NUM to return a purely numerical array or MYSQL_ASSOC to return a solely associative array).