Page 1 of 1

PHP and mySQL connection string

PostPosted: 23. March 2014 19:11
by stokie-rich
Hi guys I'm new to phpmyadmin.

I'm creating my own website and I want to let users to register and log in and to take a quiz this is the code that I have put in for the query in phpmyadmin
Code: Select all
CREATE DATABASE `dyscaculia` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

USE `dyscaculia`;

CREATE TABLE IF NOT EXISTS `users` (
  `Firstname` varchar(99) DEFAULT NULL
  `Lastname` varchar(99) DEFAULT NULL
  `Username` varchar(99) DEFAULT NULL
  `Email` decimal(99) DEFAULT NULL
  `ConfirmEmaill` varchar(99)  DEFAULT NULL
   `Password` varchar(99)  DEFAULT NULL
    `PasswordEmaill` varchar   DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;


when I run the query this is the error message that I'm getting
#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 '`Lastname` varchar(99) DEFAULT NULL
`Username` varchar(99) DEFAULT NULL
`' at line 3

can someone please help me out with this asap

thanks for any help

rich

Re: PHP and mySQL connection string

PostPosted: 23. March 2014 19:51
by JJ_Tagy
How is the DB engine supposed to identify separation of elements? You need commas.
http://dev.mysql.com/doc/refman/5.6/en/ ... ables.html

Re: PHP and mySQL connection string

PostPosted: 23. March 2014 20:00
by stokie-rich
thanks for that i will have a look at it tomorrow and let you know how I get on

Re: PHP and mySQL connection string

PostPosted: 24. March 2014 09:58
by stokie-rich
hi guys i've changed my sql query slightly to the following:

Code: Select all
/* Table dyscaculia */
CREATE  TABLE `dyscaculia_DB`.`dyscaculia` (
   
    `ID` INT(11) NOT NULL AUTO_INCREMENT,
    `first_name` VARCHAR(25) COLLATE utf8_unicode_ci DEFAULT '',
    `last_name` VARCHAR(25) COLLATE utf8_unicode_ci DEFAULT '',
    `user_name` VARCHAR(25) COLLATE utf8_unicode_ci DEFAULT '',
    `confirm_user_name` VARCHAR(25) COLLATE utf8_unicode_ci DEFAULT '',
    `pass_word` VARCHAR(25) COLLATE utf8_unicode_ci DEFAULT '',
    `confirm_pass_word` VARCHAR(25) COLLATE utf8_unicode_ci DEFAULT '',
    `e_mail` VARCHAR(25) COLLATE utf8_unicode_ci DEFAULT '',
    `user_type` INT(2) NOT NULL DEFAULT 7,
    PRIMARY KEY (`ID`)
)
ENGINE = InnoDB AUTO_INCREMENT = 1
DEFAULT CHARACTER SET = utf8 COLLATE = utf8_unicode_ci


when i run the query the following error message appears
#1049 - Unknown database 'dyscaculia_db'

Re: PHP and mySQL connection string

PostPosted: 27. March 2014 13:12
by JJ_Tagy
It seems to be saying you don't have the database created or you aren't "use"ing the database. Remember, they are case sensitive (i.e. db != DB). If you are using the correct database, you can drop the "`dyscaculia_DB`." part.