Reply
Database help - syntax and uploading
Old 04-10-2008, 07:07 AM Database help - syntax and uploading
Junior Talker

Posts: 2
Alright. First off, I'm not good with databases, so go pretty easy Also sorry if this is the wrong section.

So what we are doing - Its a project for uni, we are creating a website with an online shop (all hosted through one.com). We wish to record the sales etc on a database. Now where the database will be hosted is through phpMyAdmin. There is already a database in there called "cruisestirling_" (name of the project). This has tables in it that were created automatically when we made 2 PHPBB2 forums. So anyway, we got to work making the code (using notepad). I went to upload to phpMyAdmin what we had done and the first like said permission denied (CREATE DATABASE sales; USE sales) So got rid of that, and instead of making a new database, decided just to use the current database, and just add our tables in with the forum ones. Upon trying to upload that I got a few syntax errors, so I exported the tables that were in already, and altered what I had so it was somewhat more like the ones phpMyAdmin was already using.

So this is what our code looks like so far -

Code:
-- phpMyAdmin SQL Dump
-- version 2.9.2-Debian-1.one.com1
-- http://www.phpmyadmin.net
-- 
-- Host: MySQL Server
-- Generation Time: Apr 10, 2008 at 09:51 AM
-- Server version: 5.0.32
-- PHP Version: 5.2.0-8+etch10
-- 
-- Database: `cruisestirling_`
-- 


USE `cruisestirling_`


-- --------------------------------------------------------

-- 
-- Table structure for table `members`
-- 

CREATE TABLE `members` (    
    `member_number` mediumint (4) unsigned NOT NULL auto_increment,
    `first_name` varchar (20) unsigned NOT NULL,
    `last_name` varchar (20) unsigned NOT NULL,
    `password` varchar(20) unsigned NOT NULL,
    `date_of_birth` DATE (11) unsigned NOT NULL,
    `date_joined` DATE (11) unsigned NOT NULL,
    `email_address` varchar(50) unsigned NOT NULL),
    PRIMARY KEY (`member_number')
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;


-- --------------------------------------------------------

-- 
-- Table structure for table `transactions`
-- 
    
CREATE TABLE `transactions` (                
    `member_number` mediumint (4) unsigned NOT NULL,
    `item_number` mediumint (4) unsigned NOT NULL,
    `date_of_trans` DATE (11) unsigned NOT NULL,
    `quantity` INT (5) unsigned NOT NULL,
    `transaction_number` mediumint (255) unsigned NOT NULL auto_increment,        
    `total_cost` DOUBLE (255) unsigned NOT NULL),
    PRIMARY KEY (`transaction_number'),
    KEY (`member_number`),
    KEY (`item_number`)
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;


-- --------------------------------------------------------

-- 
-- Table structure for table `items`
-- 

CREATE TABLE `items` (                            
    `item_number` mediumint (4) unsigned NOT NULL auto_increment,            
    `item_name` varchar (20) unsigned NOT NULL,
    `item_description` varchar (255) unsigned NOT NULL,
    `unit_price` DOUBLE (255) unsigned NOT NULL),
    PRIMARY KEY (`item_number')
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;

-- 
-- Dumping data for table `phpbb_2acl_options`
-- 

INSERT INTO `items` VALUES (1, 'Keyring', 'Cruise:Stirling Keyring with logo. Black.', 4.99); 
INSERT INTO `items` VALUES (2, 'Sticker', 'Cruise:Stirling Window Sticker with logo. Black or White.', 7.99); 
INSERT INTO `items` VALUES (3, 'Cap', 'Cruise:Stirling Baseball Cap with logo. Blue.', 9.99); 
INSERT INTO `items` VALUES (4, 'TShirt', 'Cruise:Stirling T-Shirt with logo. Black or Blue in all sizes.', 14.99); 
INSERT INTO `items` VALUES (5, 'Calander', 'Cruise:Stirling Calander with various feature cars - 2009.', 14.99); 

-- --------------------------------------------------------
So when I uploaded that I get the message:

Quote:
MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE TABLE `members` (
`member_number` mediumint (4) unsigned NOT NULL auto' at line 6
Now Im sure thats not going to be the only problem. Im just pretty stumped as to what to do next, since my knowlege of this sort of stuff is minimal.

Any one have any ideas / suggestions to how I can fix this?

Thanks in advance for any replies.
RabR89 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 04-10-2008, 07:53 AM Re: Database help - syntax and uploading
Junior Talker

Posts: 2
Here is a screenshot:

http://i6.photobucket.com/albums/y23.../Problem-1.jpg
RabR89 is offline
Reply With Quote
View Public Profile
 
Old 04-14-2008, 09:31 PM Re: Database help - syntax and uploading
joder's Avatar
Flipotron

Posts: 6,084
Name: James
Location: In the ocean.
There were several errors such as an extra ). varchar and data columns cannot be unsigned since they are not numbers.

Code:
CREATE TABLE `members` (
    `member_number` mediumint(4) unsigned NOT NULL auto_increment,
    `first_name` varchar(20) NOT NULL,
    `password` varchar(20) NOT NULL,
    `date_of_birth` DATE NOT NULL,
    `date_joined` DATE NOT NULL,
    `email_address` varchar(50) NOT NULL,
    PRIMARY KEY (`member_number`)
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1;
EDIT: You'll have to fix your other tables also.

Last edited by joder : 04-14-2008 at 09:34 PM.
joder is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Database help - syntax and uploading
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11927 seconds with 13 queries