Thread: Syntax

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2005
    Posts
    15
    Rep Power
    0

    Cool Syntax


    Good Morning Team,

    I am totally grey haired now ????????

    Using phpmyadmin under plesk 11, MySQL 5.5.29

    Using SQL Tab

    If I put in

    CREATE TABLE ls_admin ( `id` bigint(10) NOT NULL, `adminname` varchar(150) NOT NULL, `username` varchar(50) NOT NULL, `password` varchar(50) NOT NULL, PRIMARY KEY (`id`) ) ENGINE = MYISAM;

    This creates a table

    But if I do it this way

    $query1="CREATE TABLE ls_admin (
    `id` bigint(10) NOT NULL DEFULT '0',
    `adminname` varchar(150) NOT NULL DEFAULT '0',
    `username` varchar(50) NOT NULL DEFAULT '0',
    `password` varchar(50) NOT NULL DEFAULT '0',
    PRIMARY KEY (`id`)
    ) ENGINE = MYISAM;";

    mysql_query($query1) or die();

    I get errors..

    eg: #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 '$query1="CREATE TABLE ls_admin (
    `id` bigint(10) NOT NULL,
    `adminname` varc' at line 1

    Can anyone tell me what is wrong please...

    All the best from Alan
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,280
    Rep Power
    4279
    Originally Posted by stewartrose
    Can anyone tell me what is wrong please...
    sure

    mysql doesn't do php

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2005
    Posts
    15
    Rep Power
    0

    Talking


    Originally Posted by r937
    sure

    mysql doesn't do php

    Ok I will except that, when I put it in an php script still don't work, same problem...

    All the best from Alan
  6. #4
  7. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Hi,

    I guess that "DEFULT" should actually be "DEFAULT".

    By the way, you should check your default values. "0" for names and a password doesn't really make sense.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Location
    Italy
    Posts
    36
    Rep Power
    2
    I agree. Also, do you plan to have billions admins in your site? BIGINT should never be used as a primary key. And must not have a default value, and it is SIGNED, and it is not AUTO_INCREMENT.

IMN logo majestic logo threadwatch logo seochat tools logo