SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Dec 2002
    Location
    Philadelphia
    Posts
    299
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Game scores in MySQL DB are strings

    I have a game for a client that submits the player high scores to a php page which then submits it to a MYSQL database.

    Everything works fine except the fact that when the user sorts the game scores on the website, the scores must be interpreted as strings, because the scores are sorting in this order: -29, 101, 15, 15, 200

    I wrote the program in Director where there is a global variable for the score that is a NUMBER, not a string.

    But Director passes the number variable using a command called postNetText() that passes things to PHP as strings. So it may be something in PHP that I need to do to designate that variable passed as a number.




    How do I let PHP or MYSQL know that this field is a number? MySQL wouldn't let me change the table field data type from "text" to "small int" ....maybe because there is data already in it?

  2. #2
    SitePoint Wizard silver trophy redemption's Avatar
    Join Date
    Sep 2001
    Location
    Singapore
    Posts
    5,269
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you're using PHP to insert the values into the database, it will automatically convert the values to numbers if you don't surround it with quotes, and if the field is a numeric field.

    Also, you should be able to change the field type from TEXT to SMALLINT. What query are you using to make the alteration?


Bookmarks

Posting Permissions

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