Solved

How to Create table in mysql5

Posted on 2008-10-17
3
547 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Generate Unique ID in VB.NET 21 103
MySQL Persistent Connections 10 33
mysql qry 1 22
Error in sql query statment. 21 44
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
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…
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.

756 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