Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2004
    Posts
    494

    Unanswered: create table syntax

    Is the following Syntax correct?
    countryValue is meant to be in 2 letters.
    countryName may range up to 50 letters
    Code:
    CREATE TABLE users ( 
    ID MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
    countryValue TINYTEXT(2), 
    countryName VARCHAR(50))
    Compare bible texts (and other tools):
    TheWheelofGod

  2. #2
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    If you tried to run this through MySQL it gives an error - so I guess the answer is no

    If you look at the error message given "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 '(2)," then this gives a pretty clear indication of where the issue is. I removed the (2) after the tinytext and it ran fine.

    Mike

    PS1 char(2) may be a better option for countryValue.

    PS2 are you sure both the countryValue and countryName fields should be in your user table - this doesn't look like good normal form to me.

  3. #3
    Join Date
    Jul 2004
    Posts
    494
    Quote Originally Posted by mike_bike_kite
    If you tried to run this through MySQL it gives an error - so I guess the answer is no :)

    If you look at the error message given "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 '(2)," then this gives a pretty clear indication of where the issue is. I removed the (2) after the tinytext and it ran fine.

    Mike

    PS1 char(2) may be a better option for countryValue.

    PS2 are you sure both the countryValue and countryName fields should be in your user table - this doesn't look like good normal form to me.
    I see your point in PS2 and changed that thanks. But I noticed there are squares after the country name which shouldn't be there (shown in the attachment picture):

    If you have an understanding of PHP it was probably because of this:
    Code:
     [2] => Array
            (
                [0] => Afghanistan
    				
                [1] => Albania
    				
                [2] => Algeria
    				
                [3] => American Samoa
    There is the space between the countries.
    That code derived from:
    PHP Code:
     $string '<SELECT NAME="country" style="border: 1px solid #990000; font-family:Arial,Helvetica,Univers,Zurich BT; ">
                    <OPTION SELECTED VALUE="US" >United States
                    <option value="AF">Afghanistan
                    <option value="AL">Albania
                    <option value="DZ">Algeria
    ...
                </SELECT>'
    ;

    preg_match_all("#<option value=\"([^\"]+)\">([^<]+)#"$string$foo);

    print_r($foo);  //value in foo[1], contents and foo[2] 
    Attached Thumbnails Attached Thumbnails squares.jpg  
    Compare bible texts (and other tools):
    TheWheelofGod

  4. #4
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    The spaces seem to be appearing fine in your array and spaces are also not a problem in MySQL so I suspect the issue is in the logic in between. I personally learnt PHP/MySQL by just getting a good book and working my way through the examples - this method might help you as well.

    Mike

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    the square symbols look to me like non printable characters so Id suggest you check your data for trailing characters after the country name
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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