I'm having

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

    #1

    I'm having

    Hi every one

    I having problem using count() function
    when I use count() the result came multiply 2

    and this is my code :

    ////////////////////////////////////

    $sql2 = "select * from user_previlag WHERE User_email= '$userEmail'";
    $data2 = mysql_query($sq l2);
    $info = mysql_fetch_arr ay($data2);

    echo count($info);

    \\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\\\\
  • =?iso-8859-1?Q?=C1lvaro?= G. Vicario

    #2
    Re: I'm having

    *** sahm escribió/wrote (Sat, 20 Sep 2008 01:57:28 -0700 (PDT)):
    I having problem using count() function
    when I use count() the result came multiply 2
    >
    and this is my code :
    >
    ////////////////////////////////////
    >
    $sql2 = "select * from user_previlag WHERE User_email= '$userEmail'";
    $data2 = mysql_query($sq l2);
    $info = mysql_fetch_arr ay($data2);
    >
    echo count($info);
    From http://php.net/mysql_fetch_array:

    array mysql_fetch_arr ay ( resource $result [, int $result_type ] )

    result_type: The type of array that is to be fetched. It's a constant and
    can take the following values: MYSQL_ASSOC, MYSQL_NUM, and the default
    value of MYSQL_BOTH.

    Return Values: [...] The type of returned array depends on how result_type
    is defined. By using MYSQL_BOTH (default), you'll get an array with both
    associative and number indices.



    So your problem has nothing to do with count(). Also, have a look at
    Prints human-readable information about a variable



    --
    -- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
    -- Mi sitio sobre programación web: http://bits.demogracia.com
    -- Mi web de humor en cubitos: http://www.demogracia.com
    --

    Comment

    • Kari Hanski

      #3
      Re: I'm having

      sahm <sahm007@gmail. comkirjoitti 20.09.2008:
      >
      I having problem using count() function
      when I use count() the result came multiply 2
      >
      and this is my code :
      >
      ////////////////////////////////////
      >
      $sql2 = "select * from user_previlag WHERE User_email= '$userEmail'";
      $data2 = mysql_query($sq l2);
      $info = mysql_fetch_arr ay($data2);
      >
      echo count($info);
      >
      \\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\\\\
      You should be using mysql_num_rows( ) function.

      If you do print_r($info), you'll see why count() does that.

      Comment

      Working...