Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

simple php/mysql questions

  • 21-07-2009 11:02am
    #1
    Registered Users, Registered Users 2 Posts: 8,070 ✭✭✭


    When injecting an integer like 0024, mysql or perhaps php omitts the first two 0's and enters 24,
    tried using varchar/text, no luck.


Comments

  • Registered Users, Registered Users 2 Posts: 9,225 ✭✭✭Chardee MacDennis


    just cast it as a string first...


  • Registered Users, Registered Users 2 Posts: 9,579 ✭✭✭Webmonkey


    or if you printing and it will always be 4 digits:

    [php]printf("The number is %04d", 24);[/php]

    But it looks like you mean when storing in a DB. Having 0's before an integer has no meaning to an integer type so they are ommitted. As above, use a char/string instead.


  • Registered Users, Registered Users 2 Posts: 8,070 ✭✭✭Placebo


    doesnt work ? varchar data type...

    tried


    $code1 = "$code[0]";

    and

    $code1 = (string)$code[0];

    //its an array value.




    Just gonna use zerofill in type INT, and limit it to 4, so 24 will be 0024, this field will always be 4 digits max so it works out
    but not sure why other stuff didnt work, annoying...


  • Closed Accounts Posts: 18,163 ✭✭✭✭Liam Byrne


    str_pad_left ?


  • Closed Accounts Posts: 1,200 ✭✭✭louie


    set the field as "varchar. int or numeric will remove the 0


  • Advertisement
Advertisement