Always making Ints 2 chars long

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default Always making Ints 2 chars long

    Hello all,

    I'm trying to create a menu bar option of posts in the past 5 months. I do
    this by getting the month from date('m'), and then subtracting 1 from it
    each time, However the problem is that whenever I subtract 1 it goes to
    single figures, which ruins the sql query. Is there anyway to convert the
    value from 6 to 06..etc?

    Regards
    Peter Akrill
    --
    /********************************************
    No Electrons were harmed during
    making of this message
    [url]http://darkflame.sinisterkitten.co.uk[/url]
    *********************************************/


    Peter Akrill Guest

  2. Similar Questions and Discussions

    1. Question about a long session timeout (somewhat long)
      I've been told by my developers to increase the asp.net session timeout to 72 hours. Being a server guy, it concerns me because of the obvious...
    2. #39916 [NEW]: Auto trunkation of floats to ints in array indices should raise a warning
      From: thuejk at gmail dot com Operating system: All PHP version: 5.2.0 PHP Bug Type: Feature/Change Request Bug description:...
    3. String Literal Too Long - (less than 4000 chars)
      We have a form field where users enter in a status (free text, any characters, etc). Not in every case, but a good portion of the time, when a user...
    4. ORA 01704:...too long; Only inserting 800 chars
      Hi, I am trying to insert text into a VARCHAR2 (4000) database field in Oracle 8.1.7. We are using CF Server Version 5. The text that is being...
    5. receiving ??? chars instead of "special" chars
      Hello i have a strange problem i made a online catalogue and must submit orders to a remote server I need to connect to a remote webservice on ...
  3. #2

    Default Re: Always making Ints 2 chars long

    "Peter Akrill" wrote:
    > Hello all,
    >
    > I’m trying to create a menu bar option of posts in the past 5
    > months. I do
    > this by getting the month from date(’m’), and then
    > subtracting 1 from it
    > each time, However the problem is that whenever I subtract 1 it
    goes
    > to
    > single figures, which ruins the sql query. Is there anyway to
    convert
    > the
    > value from 6 to 06..etc?
    >
    > Regards
    > Peter Akrill
    What is the query you are trying to execute?

    --
    [url]http://www.dbForumz.com/[/url] This article was posted by author's request
    Articles individually checked for conformance to usenet standards
    Topic URL: [url]http://www.dbForumz.com/PHP-making-Ints-chars-long-ftopict146492.html[/url]
    Visit Topic URL to contact author (reg. req'd). Report abuse: [url]http://www.dbForumz.com/eform.php?p=490477[/url]
    steve Guest

  4. #3

    Default Re: Always making Ints 2 chars long

    if( $month < 10 ){
    $month = "0" . $month;
    }

    or you can check the length using substr and if the length
    is less than 2 add leading 0


    "steve" <UseLinkToEmail@dbForumz.com> wrote in message
    news:413a0032$1_5@alt.athenanews.com...
    > "Peter Akrill" wrote:
    > > Hello all,
    > >
    > > I'm trying to create a menu bar option of posts in the past 5
    > > months. I do
    > > this by getting the month from date('m'), and then
    > > subtracting 1 from it
    > > each time, However the problem is that whenever I subtract 1 it
    > goes
    > > to
    > > single figures, which ruins the sql query. Is there anyway to
    > convert
    > > the
    > > value from 6 to 06..etc?
    > >
    > > Regards
    > > Peter Akrill
    >
    > What is the query you are trying to execute?
    >
    > --
    > [url]http://www.dbForumz.com/[/url] This article was posted by author's request
    > Articles individually checked for conformance to usenet standards
    > Topic URL:
    > [url]http://www.dbForumz.com/PHP-making-Ints-chars-long-ftopict146492.html[/url]
    > Visit Topic URL to contact author (reg. req'd). Report abuse:
    > [url]http://www.dbForumz.com/eform.php?p=490477[/url]

    Mr. Foo Guest

  5. #4

    Default Re: Always making Ints 2 chars long

    Mr. Foo wrote:
    > if( $month < 10 ){
    > $month = "0" . $month;
    > }
    >
    > or you can check the length using substr and if the length
    > is less than 2 add leading 0
    >
    Or just do (s)printf("%02d", $month);


    JW



    Janwillem Borleffs Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139