mysql_fetch_array result type error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Karl Groves

    mysql_fetch_array result type error

    I'm trying to run mysql_fetch_arr ay with a variable in place of the
    optional result type constant, like so

    mysql_fetch_arr ay($result, $rtype) where, obviously, $rtype is one of the
    three valid values for the result type. This throws an error:
    "mysql_fetch_ar ray() [function.mysql-fetch-array]: The result type should
    be either MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH."

    I'm not quite sure what the issue here is, other than that I'm replacing a
    constant with a variable. I'm looking for a solution that will allow me to
    (variably) be able to dictate this value.

    TIA

    --
    Karl Groves

  • Hendri Kurniawan

    #2
    Re: mysql_fetch_arr ay result type error

    Karl Groves wrote:
    I'm trying to run mysql_fetch_arr ay with a variable in place of the
    optional result type constant, like so
    >
    mysql_fetch_arr ay($result, $rtype) where, obviously, $rtype is one of the
    three valid values for the result type. This throws an error:
    "mysql_fetch_ar ray() [function.mysql-fetch-array]: The result type should
    be either MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH."
    >
    I'm not quite sure what the issue here is, other than that I'm replacing a
    constant with a variable. I'm looking for a solution that will allow me to
    (variably) be able to dictate this value.
    >
    TIA
    >
    I assume your variable $rtype contains string of the constants.
    "MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH" are CONSTANTS.
    As such, $rtype need to contains the value of the constants.
    ie. assign $rtype = MYSQL_NUM *NOT* $rtype = 'MYSQL_NUM'
    (Note the quote)

    Hendri

    Comment

    • Karl Groves

      #3
      Re: mysql_fetch_arr ay result type error

      Hendri Kurniawan <ask-me@email.comwro te in
      news:1306k88t4b qh0aa@corp.supe rnews.com:
      Karl Groves wrote:
      >I'm trying to run mysql_fetch_arr ay with a variable in place of the
      >optional result type constant, like so
      >>
      >mysql_fetch_ar ray($result, $rtype) where, obviously, $rtype is one of
      >the three valid values for the result type. This throws an error:
      >"mysql_fetch_a rray() [function.mysql-fetch-array]: The result type
      >should be either MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH."
      >>
      >I'm not quite sure what the issue here is, other than that I'm
      >replacing a constant with a variable. I'm looking for a solution
      >that will allow me to (variably) be able to dictate this value.
      >>
      >TIA
      >>
      >
      I assume your variable $rtype contains string of the constants.
      "MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH" are CONSTANTS.
      As such, $rtype need to contains the value of the constants.
      ie. assign $rtype = MYSQL_NUM *NOT* $rtype = 'MYSQL_NUM'
      (Note the quote)
      >
      UGH. So simple. Thanks



      --
      Karl Groves

      Comment

      Working...