Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 20

Thread: Phpmyadmin

  1. #1
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts

    Phpmyadmin

    when making a table with PHP my admin i press save and it gives me a javascript alert saying this is not a number most fields are varchar bar 2 which one of them is longtext (for descriptions) other is tinyint (for level) if you want more details of the table ill post them, i've also not put any length values in on any of them, should i?

  • #2
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    dw i just remembered that varchar needs a max length

    now gives me
    Code:
         MySQL said:  
      #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 'UNSIGNED CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, `password` VARCHAR' at line 1
    this is the create table code
    PHP Code:
                      CREATE  TABLE  `users` ( `usernameVARCHAR20  )  UNSIGNED NOT  NULL ,
     `
    passwordVARCHAR20  )  UNSIGNED NOT  NULL ,
     `
    emailVARCHAR50  )  UNSIGNED NOT  NULL ,
     `
    useridVARCHAR6  )  UNSIGNED NOT  NULL  AUTO_INCREMENT  PRIMARY  KEY ,
     `
    levelTINYINT3  )  UNSIGNED NOT  NULL DEFAULT  '1',
     `
    countryVARCHAR15  )  UNSIGNED NOT  NULL ,
     `
    genderVARCHAR6  )  UNSIGNED NOT  NULL ,
     `
    imtypeVARCHAR15  )  UNSIGNED NOT  NULL ,
     `
    imnameVARCHAR50  )  UNSIGNED NOT  NULL ,
     `
    ageVARCHAR2  )  UNSIGNED NOT  NULL ,
     `
    houseVARCHAR20  )  UNSIGNED NOT  NULL DEFAULT  'bus shelter',
     `
    clanVARCHAR20  )  UNSIGNED NOT  NULL DEFAULT  'n\\a',
     `
    jobVARCHAR20  )  UNSIGNED NOT  NULL DEFAULT  'n\\a',
     `
    moneyVARCHAR20  )  UNSIGNED NOT  NULL DEFAULT  '1000',
     `
    membertypeVARCHAR4  )  UNSIGNED NOT  NULL DEFAULT  'free',
     `
    itemsLONGTEXT  UNSIGNED NOT  NULL DEFAULT  '0',
     `
    rankVARCHAR3  )  UNSIGNED NOT  NULL DEFAULT  '1'ENGINE  =  MYISAM 
    Last edited by rafiki; 03-22-2007 at 03:48 AM.

  • #3
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,634
    Thanks
    4
    Thanked 148 Times in 139 Posts
    char/varchar field can't be UNSIGNED, that is for numeric data field.
    also why use LONGTEXT for a field and then sign a numeric default to it?

  • #4
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    coz if its set to 0 then i can echo none, spose i could do that the same way i check if a username is taken or there email address is already registered
    now i get this
    PHP Code:
    SQL query:     
                  
    CREATE  TABLE  `users` ( `usernameVARCHAR20  )  NOT  NULL ,
     `
    passwordVARCHAR20  )  NOT  NULL ,
     `
    emailVARCHAR50  )  NOT  NULL ,
     `
    useridVARCHAR6  )  NOT  NULL  AUTO_INCREMENT  PRIMARY  KEY ,
     `
    levelTINYINT3  )  NULL DEFAULT  '1',
     `
    countryVARCHAR15  )  NULL ,
     `
    genderVARCHAR6  )  NULL ,
     `
    imtypeVARCHAR15  )  NOT  NULL ,
     `
    imnameVARCHAR50  )  NOT  NULL ,
     `
    ageVARCHAR2  )  NOT  NULL ,
     `
    houseVARCHAR20  )  NOT  NULL DEFAULT  'bus shelter',
     `
    clanVARCHAR20  )  NOT  NULL DEFAULT  'n\\a',
     `
    jobVARCHAR20  )  NOT  NULL DEFAULT  'n\\a',
     `
    moneyVARCHAR20  )  UNSIGNED NOT  NULL DEFAULT  '1000',
     `
    membertypeVARCHAR4  )  NOT  NULL DEFAULT  'free',
     `
    itemsLONGTEXT NOT  NULL DEFAULT  '0',
     `
    rankVARCHAR3  )  NOT  NULL DEFAULT  '1'ENGINE  =  MYISAM      
          MySQL said
    : [IMG]http://localhost/phpmyadmin/themes/darkblue_orange/img/b_help.png [/IMG] 
      #1063 - Incorrect column specifier for column 'userid' 
    Last edited by rafiki; 03-22-2007 at 02:41 PM.

  • #5
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,634
    Thanks
    4
    Thanked 148 Times in 139 Posts
    what are you inputting in the LONGTEXT type column? You realize it can hold a vast amount of text right?
    4294967296 bytes or about (4 GiB) of storeage?

    You should also look into the use of NULL as that is what you want when an item is undefined.

    With the use of NULL you can also use COALESCE to show no user if the value isn't available.

    Code:
    SELECT
    COALESCE(username,'none') as name
    FROM yourtablename
    would show None when a username has not been filled in for a user that has other info in their row (id and age existing in the row for example but not their name).
    Last edited by guelphdad; 03-22-2007 at 02:48 PM.

  • #6
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    `imtype` VARCHAR( 15 ) NOT NULL ,
    `
    imname` VARCHAR( 50 ) NOT NULL ,
    those two fields are the only ones which will not need data inputted by a user, most of them will be filled in by php
    i know next to nothing about mysql which is why i am trying this project
    would you like to see some php code from this page



  • #7
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,634
    Thanks
    4
    Thanked 148 Times in 139 Posts
    You have created a column as above with LONGTEXT as the data type and then set a default of 0. I'm asking why you set a default of a numeric value?

    Then I'm asking if you realize that the size of the data you can store in a longtext field is in the order of 4 gigabytes?

    Don't create a datatype that you don't need.

  • #8
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    ok what should i use, i need to put a pretty long list of items in and then array them when i fetch them i can echo out singlely
    for example the field will hold = chocolate, computer, keyboard, forum, smillies, attachment,
    then i need to fetch them explode() them assign them to there own var then echo out something like you own $var $var1 $var2 $var3 and own a total of $amount items, understand, like i sed i no next to nothing about mysql and cant find the table drew out for what r field types to use,

  • #9
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,634
    Thanks
    4
    Thanked 148 Times in 139 Posts
    There is a problem right there. You should NEVER store data in a string of values. Check this article to explain the drawbacks of doing so.

  • #10
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    im kinda busy atm, but i did read bit of it, does that mean i need to join to tables
    how would igo about that
    -------------+-----------+--------------
    username | items | otherfield |
    -----------------------------------------
    rafiki | football, | something |
    -----------------------------------------
    admin | football, | something |
    ______| boots, |______|
    ______| gloves |______|
    -----------------------------------------
    thats how i wanted it to look
    then when the admin wanted to see wat items he had it would show
    football
    boots
    gloves
    you own a total of 3 items
    Last edited by rafiki; 03-22-2007 at 07:29 PM.

  • #11
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    is that not possible/recommended? plz guys i need help with this i changed the items field to normal text

  • #12
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    noone?

  • #13
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    I kind of got lost-- what is your question?

  • #14
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    i need to store, what would be a list in html into a table, for example the admin has 5 items
    football boots, football, pizza, chips, chicken
    i have just 2
    chicken, chips
    i need to store them into a database and be able to store them 2 an array or something then explode them into single vars
    then count how many there were
    make sense? i think thats the best way to describe it :S

  • #15
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Just store each item individually into its own field in your database and use a while or for loop to fetch them. You are probably going to have to limit the number of items each user has.
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •