Solved

How to Create table in mysql5

Posted on 2008-10-17
3
550 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

623 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