I'm messing with PHP and I need a MySQL database with 5 fields, id, real_name, username, password, and email. How do I go about making one?
Thanks,
- Allen
Printable View
I'm messing with PHP and I need a MySQL database with 5 fields, id, real_name, username, password, and email. How do I go about making one?
Thanks,
- Allen
You mean you need a table with that? Tables hold records. Databases hold tables.
The easiest way would be to download phpMyAdmin and use it to create your tables.
Otherwise you'd have to do something like this:
Code://the below was generated with phpMyAdmin:
$sql = 'CREATE TABLE `table1` (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT,
`real_name` VARCHAR( 50 ) NOT NULL ,
`username` VARCHAR( 16 ) NOT NULL ,
`password` VARCHAR( 16 ) NOT NULL ,
`email` VARCHAR( 255 ) NOT NULL ,
INDEX ( `id` )
);'
$result = mysql_query($sql) or die(mysql_error());
if ($result) {
echo "Success!";
} else {
echo "Failure...";
}
hmmmm..... Perhaps I mean table... I know absolutely nothing.... I'm trying to follow the instructions on the site below:
http://www.evilwalrus.com/viewcode/24.php
Do I need a table or a DB or both ?
- Allen
Well, both :p
(I havnt read that link, but ...) you'll need to know roughly how to access these commands :p do you know how to get to the "MySQL Monitor" ?? (its that DOS based, Mysql command console)
you'rer actually quite better off readinf a bit of the manual (beginners section) before even trying to accomplish this ;) just so you know the basics of making and using a database (before even trying tables).
Manual ? There's a manual ?
If you're using windows, phpTraid won't be a bad idea, search for it on www.download.com
www.php.net -- A must.
php.net isn't going to do him a lick of good on how to create a database...Quote:
Originally posted by SystemShock
If you're using windows, phpTraid won't be a bad idea, search for it on www.download.com
www.php.net -- A must.
LOL.... when you guys get sorted out what I should do, let me know. :D
Hobo, did you look at the site up there ^ to see what I'm trying to copy ?
- Allen
You need a mysql server.
Then you need to create a database under the name of "secretDB"
You could change the name of the database to another, if you are assigned one by a free provider..
Basically, you need a mysql server on which you either have root access - to create databases, or where you have access to a current database.
Then you can connect using the standard php commands ->
mysql_connect etc
clearer now?