PDA

View Full Version : MySQL Please Help!



diggakid
06-01-2010, 12:14 PM
Hello i have just started learning PHP and MySQL and have taken up my 3rd project which is starting to heavily rely on the MySQL database to store information.

Im coding a shopping cart for personal use and have made a .sql document to create the database and tables for me but when i load the script via phpmyadmin and error keeps stopping me from creating the tables.

im testing the scripts on a local host

please help

here is my script:


create database cart_sc;

use cart_sc;

create table customer_details
(
order_number int unsigned not null auto_increment primary key,
first_name char(60) not null,
last_name char(60) not null,
address char(80) not null,
city char(30) not null,
state char(20) not null,
zip varchar(10) not null,
country char(20) not null,
email varchar(100) not null,
phone int(20) not null,
);

create table orders
(
order_number int unsigned not null auto_increment primary key,
date date not null,
order_status char(10) not null,
server_name char(60) not null,
server_type char(255) not null,
server_slots char(30) not null,
server_brand char(20) not null,
total_price float(4,2) not null,
);

grant select, insert, update, delete
on cart_sc.*
to cart_sc@localhost identified by 'password';

Morgenmuffel
06-01-2010, 01:27 PM
What does the error say

HAL9000
06-01-2010, 01:40 PM
create table customer_details
(
order_number int unsigned not null auto_increment primary key,
first_name char(60) not null,
last_name char(60) not null,
address char(80) not null,
city char(30) not null,
state char(20) not null,
zip varchar(10) not null,
country char(20) not null,
email varchar(100) not null,
phone int(20) not null, <<---- Extra Comma here.
);

Remove that and it works. Repeat for all other table where you have a comma after the last field.

Erayd
06-01-2010, 09:27 PM
Also - why are you using the char datatype in most of those fields? Varchar is usually a better choice for that kind of data.