I'm having

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

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($sql2);
        $info = mysql_fetch_array($data2);

        echo count($info);


Re: I'm having

*** sahm escribió/wrote (Sat, 20 Sep 2008 01:57:28 -0700 (PDT)):
Quoted text here. Click to load it

From http://php.net/mysql_fetch_array :

array mysql_fetch_array  ( 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

-- 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

Re: I'm having

Quoted text here. Click to load it

You should be using mysql_num_rows() function.

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

Site Timeline