Solved

How to Create table in mysql5

Posted on 2008-10-17
3
538 Views
Last Modified: 2013-12-13
i m developing a login page with the combination of php and mysql, how i can create a table which stores usernames and password and other informations ?
0
Comment
Question by:cbpandya
3 Comments
 
LVL 13

Accepted Solution

by:
marchent earned 250 total points
ID: 22740851
http://sql-info.de/mysql/examples/CREATE-TABLE-examples.html
http://www.tizag.com/mysqlTutorial/mysqltables.php
create table info(

    username varchar(255) not null,

    password varchar(255) not null,

    firstname varchar(2255) not null,

    primary key(username)

);

Open in new window

0
 
LVL 8

Expert Comment

by:MatthiasVance
ID: 22740863
I hope this helps you.

Kind regards,

Matthias Vance
<?php

	// Connect to DB server

	$connection = mysql_connect(DB_HOST, DB_USER, DB_PASS);

	// Select database

	mysql_select_db("ee_test");

	// Initialize query

	$query = "CREATE TABLE `ee_test`.`users` ("

	$query .= "  `username` VARCHAR(255) NOT NULL,"

	$query .= "  `password` VARCHAR(32) NOT NULL,"

	$query .= "  `fullname` VARCHAR(255) NOT NULL,"

	$query .= "  `country` VARCHAR(255) NOT NULL,"

	$query .= "  PRIMARY KEY (`username`)"

	$query .= ")"

	$query .= "ENGINE = InnoDB;"

	// Execute query

	mysql_query($query, $connection);

	// Insert something to our newly created table

	$query = "INSERT INTO `ee_test`.`users` VALUES('mvance', MD5(test), 'Matthias Vance', 'N/A');"

	mysql_query($query, $connection);

?>

Open in new window

0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now