PHP and mySQL connection string

Und alles was mit phpMyAdmin seine Verwandtschaft findet hat hier seinen Platz.

PHP and mySQL connection string

Postby stokie-rich » 23. March 2014 19:11

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
stokie-rich
 
Posts: 4
Joined: 23. March 2014 19:07
Operating System: wn 7

Re: PHP and mySQL connection string

Postby JJ_Tagy » 23. March 2014 19:51

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
JJ_Tagy
 
Posts: 788
Joined: 30. January 2012 13:44
XAMPP version: 5.5.15
Operating System: Windows 10 Pro x64

Re: PHP and mySQL connection string

Postby stokie-rich » 23. March 2014 20:00

thanks for that i will have a look at it tomorrow and let you know how I get on
stokie-rich
 
Posts: 4
Joined: 23. March 2014 19:07
Operating System: wn 7

Re: PHP and mySQL connection string

Postby stokie-rich » 24. March 2014 09:58

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'
stokie-rich
 
Posts: 4
Joined: 23. March 2014 19:07
Operating System: wn 7

Re: PHP and mySQL connection string

Postby JJ_Tagy » 27. March 2014 13:12

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.
JJ_Tagy
 
Posts: 788
Joined: 30. January 2012 13:44
XAMPP version: 5.5.15
Operating System: Windows 10 Pro x64


Return to phpMyAdmin

Who is online

Users browsing this forum: No registered users and 93 guests