Jump to content

Creating a databae


JC5

Recommended Posts

Ok i have this code and i have to create a database and im following some instructions. go to the url i posted below and i have a question. how do i get this to work. do i just put it in a text file and save? or wrap it in <?php ?> tags or what. also when u go to the page do i save this as db.php?

CREATE TABLE `users` (  `ID` int(11) NOT NULL auto_increment,  `Username` varchar(255) NOT NULL,  `Password` varchar(255) NOT NULL,  `Temp_pass` varchar(55) default NULL,  `Temp_pass_active` tinyint(1) NOT NULL default '0',  `Email` varchar(255) NOT NULL,  `Active` int(11) NOT NULL default '0',  `Level_access` int(11) NOT NULL default '2',  `Random_key` varchar(32) default NULL,  PRIMARY KEY  (`ID`),  UNIQUE KEY `Username` (`Username`),  UNIQUE KEY `Email` (`Email`)) ENGINE=MyISAM;

Link:herethanks

Link to comment
Share on other sites

You can create the table from a PHP script, just put the query within the mysql_query() function.Your profile says you know both PHP and MySQL, this is pretty simple to understand.

Link to comment
Share on other sites

I went to the link. They assume you know what you're doing. What you quoted was a query string that needs to go into one of the many PHP commands that access MySQL. If you scroll down that link you'll see some more normal PHP interface. Go here for a more deliberate example http://www.php.net/manual/en/mysql.examples.phpYour workhorse commands are listed below in the order you'd normally use them. mysql_query is the one that does the real work. You'll call it over and over while the database is open. It accepts query strings like the one you quoted. Don't be confused by the word "query." Whether putting data IN or reading it OUT, everything you do is a query.mysql_connectmysql_select_dbmysql_querymysql_free_resultmysql_close

Link to comment
Share on other sites

Btw that code doesn't create a database, it creates a table. Many hosts don't give CREATE DATABASE rights to their clients for security reasons so don't be surprised if your CREATE DATABASE query doesn't work - you will probably have to use your database management tool (e.g. cPanel).

Link to comment
Share on other sites

thats what i meant. it turned out i didnt have to go to soccer game so i spent that time hand coding my register page. you can go to www.devwebsites.com/register.php and check it out. I just finished! tell me if you see any security errors that could be implemented btw because I no thats a fig flag with some register/login scripts

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...