2006/7 interpret as 2006 divide by 7 instead of a string

Discussion in 'PHP' started by rosytoes, Aug 9, 2006.

  1. #1
    I have $temp="2006/7"; I insert this into a table field where its datatype is char(12). However, this seems to be interpreted as 2006 divided by 7 instead of putting the string in the table. Is there a way to force "2006/7" to be read as a string?
     
    rosytoes, Aug 9, 2006 IP
  2. haentz

    haentz Peon

    Messages:
    78
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Is PHP doing this wrong or the Database? If the DB field is a char it shouldn't be the DB. Weird... But that's why I don't like the not type-safe PHP scripting language ;)

    Try this in your PHP script: $temp="2006"."/7";


    Kind regards, Hans
     
    haentz, Aug 9, 2006 IP
  3. rosytoes

    rosytoes Peon

    Messages:
    230
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Finally got it to work. I had set the default of that field to 2006/7, it was actually storing 286.57 in the database. I took the default out and $temp="2006/7"; work fine.
     
    rosytoes, Aug 9, 2006 IP