Solved

How to Create table in mysql5

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
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.

738 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