equality and TINYINT field?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Geoff Cox

    #16
    Re: equality and TINYINT field?

    On Wed, 13 Aug 2008 02:58:39 -0700 (PDT), Captain Paralytic
    <paul_lautman@y ahoo.comwrote:

    >
    >$row doesn't get a value until you assign one.
    >So if you do:
    >$row = mysql_fetch_arr ay($result))
    >echo "@{$row['group1']}@"
    OK - get it.

    Thanks

    Geoff

    Comment

    • Geoff Cox

      #17
      Re: equality and TINYINT field?

      On Wed, 13 Aug 2008 11:05:18 +0100, Geoff Berrow
      <blthecat@ckdog .co.ukwrote:
      >Message-ID: <fo35a4hg59mhcn 5lois3ohsgga3g1 jnone@4ax.comfr om Geoff Cox
      >contained the following:
      >
      >>
      >>while ($row = mysql_fetch_arr ay($result)) {
      >>($row['group1'] == 1) { etc
      >>
      >>this works.
      >>
      >>Outside the loop $row['group1'] is empty (or NULL?)
      >>
      >>Why is this?
      >
      ><fx: smacks head>
      >For every iteration of $row = mysql_fetch_arr ay($result) then
      >$row['group1'] will have a different value corresponding to the entry in
      >the database for that particular row. Outside the loop (below the while
      >loop in the code) $row['group1'] will have the value corresponding to
      >the last row of the database query.

      Thanks - it came to me on the way home just now on my bike!

      Cheers

      Geoff

      Comment

      • The Natural Philosopher

        #18
        Re: equality and TINYINT field?

        Geoff Berrow wrote:
        Message-ID: <fo35a4hg59mhcn 5lois3ohsgga3g1 jnone@4ax.comfr om Geoff Cox
        contained the following:
        >
        >while ($row = mysql_fetch_arr ay($result)) {
        >($row['group1'] == 1) { etc
        >>
        >this works.
        >>
        >Outside the loop $row['group1'] is empty (or NULL?)
        >>
        >Why is this?
        >
        <fx: smacks head>
        For every iteration of $row = mysql_fetch_arr ay($result) then
        $row['group1'] will have a different value corresponding to the entry in
        the database for that particular row. Outside the loop (below the while
        loop in the code) $row['group1'] will have the value corresponding to
        the last row of the database query.
        >
        No it wont. It wil have a NULL value assigned, as it is the failure of
        $row to be anything other than null that *causes the loop to exit*.

        Comment

        • Geoff Berrow

          #19
          Re: equality and TINYINT field?

          Message-ID: <1218653158.289 78.4@proxy00.ne ws.clara.netfro m The Natural
          Philosopher contained the following:
          ><fx: smacks head>
          >For every iteration of $row = mysql_fetch_arr ay($result) then
          >$row['group1'] will have a different value corresponding to the entry in
          >the database for that particular row. Outside the loop (below the while
          >loop in the code) $row['group1'] will have the value corresponding to
          >the last row of the database query.
          >>
          >No it wont. It wil have a NULL value assigned, as it is the failure of
          >$row to be anything other than null that *causes the loop to exit*.
          Hmm, good point. In practice you wouldn't normally have a use for $row
          outside the loop so it's never an issue.
          --
          Geoff Berrow 011000100110110 0010000000110
          001101101011011 001000110111101 100111001011
          100110001101101 111001011100111 010101101011
          The Slippery Hill Boys Tel: 07985 425932. American themed barn dances and bluegrass performances. Stoke on Trent, Newcastle under Lyme, Staffordshire, Cheshire and surrounding areas.

          Comment

          • Geoff Cox

            #20
            Re: equality and TINYINT field?

            On Wed, 13 Aug 2008 19:45:58 +0100, The Natural Philosopher <a@b.c>
            wrote:
            >Geoff Berrow wrote:
            >Message-ID: <fo35a4hg59mhcn 5lois3ohsgga3g1 jnone@4ax.comfr om Geoff Cox
            >contained the following:
            >>
            >>while ($row = mysql_fetch_arr ay($result)) {
            >>($row['group1'] == 1) { etc
            >>>
            >>this works.
            >>>
            >>Outside the loop $row['group1'] is empty (or NULL?)
            >>>
            >>Why is this?
            >>
            ><fx: smacks head>
            >For every iteration of $row = mysql_fetch_arr ay($result) then
            >$row['group1'] will have a different value corresponding to the entry in
            >the database for that particular row. Outside the loop (below the while
            >loop in the code) $row['group1'] will have the value corresponding to
            >the last row of the database query.
            >>
            >No it wont. It wil have a NULL value assigned, as it is the failure of
            >$row to be anything other than null that *causes the loop to exit*.
            in fact that's what I found - a null value - which made me think I
            need to test within the while loop.

            Cheers

            Geoff

            Comment

            • Geoff Berrow

              #21
              Re: equality and TINYINT field?

              Message-ID: <jhg6a4dfkqe0e9 drtc2olg73hlh0r u3k8r@4ax.comfr om Geoff Cox
              contained the following:
              >in fact that's what I found - a null value - which made me think I
              >need to test within the while loop.
              You're still not getting it are you?
              --
              Geoff Berrow 011000100110110 0010000000110
              001101101011011 001000110111101 100111001011
              100110001101101 111001011100111 010101101011
              The Slippery Hill Boys Tel: 07985 425932. American themed barn dances and bluegrass performances. Stoke on Trent, Newcastle under Lyme, Staffordshire, Cheshire and surrounding areas.

              Comment

              • The Natural Philosopher

                #22
                Re: equality and TINYINT field?

                Geoff Cox wrote:
                On Wed, 13 Aug 2008 19:45:58 +0100, The Natural Philosopher <a@b.c>
                wrote:
                >
                >Geoff Berrow wrote:
                >>Message-ID: <fo35a4hg59mhcn 5lois3ohsgga3g1 jnone@4ax.comfr om Geoff Cox
                >>contained the following:
                >>>
                >>>while ($row = mysql_fetch_arr ay($result)) {
                >>>($row['group1'] == 1) { etc
                >>>>
                >>>this works.
                >>>>
                >>>Outside the loop $row['group1'] is empty (or NULL?)
                >>>>
                >>>Why is this?
                >><fx: smacks head>
                >>For every iteration of $row = mysql_fetch_arr ay($result) then
                >>$row['group1'] will have a different value corresponding to the entry in
                >>the database for that particular row. Outside the loop (below the while
                >>loop in the code) $row['group1'] will have the value corresponding to
                >>the last row of the database query.
                >>>
                >No it wont. It wil have a NULL value assigned, as it is the failure of
                >$row to be anything other than null that *causes the loop to exit*.
                >
                in fact that's what I found - a null value - which made me think I
                need to test within the while loop.
                >
                Indeed. That is exactly what the code should give you: a null result.

                I am not sure what you were TRYING to achieve with that code fragment,
                but the problem has nothing to do with equality and tinyints..


                Cheers
                >
                Geoff

                Comment

                Working...