473,382 Members | 1,424 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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

echo count($info);

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Sep 20 '08 #1
2 1295
*** 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($sql2);
$info = mysql_fetch_array($data2);

echo count($info);
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://php.net/print_r
--
-- 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
--
Sep 20 '08 #2
sahm <sa*****@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($sql2);
$info = mysql_fetch_array($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.

Sep 20 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: George | last post by:
Hi, I am trying to write a query in Oracle which I have not done before, and are having some difficulty getting my result. Please check my query and my results. select max(note.datetime),...
0
by: Graham Simms | last post by:
I have tried to run a query where the reuslts are restricted by a HAVING clause with 2 conditions, but the second condition seems to be ignored. for example SELECT userid, AVG(position) FROM...
1
by: malcolm | last post by:
Hello, We have a small team building a project that involves some 30 or so c# assembly dlls. It is a client server application with 1 exe as the starting point. The dlls and exe are sharing an...
7
by: | last post by:
I fail to understand why that the memory allocated in the void create(int **matrix) does not remain. I passed the address of matrix so shouldn't it still have the allocated memory when it returns...
4
by: don | last post by:
I have two existing interfaces having methods with same names. Now I have to implement both intrfaces in one class. Is there any way I could implement methods with same names in both interfaces...
11
by: Jeff Robichaud | last post by:
Are there any security issues having the ASPNET user account member of Administrators ? Is it a good practice ?
2
by: sanderson82 | last post by:
Hi I am having problems with the HAVING clause. I know it can use aliases but the alias I am using has a space in it, eg 'Device ID' My querry looks like (simplified, devID is a calculation) ...
12
by: Edward Diener | last post by:
Given value class X { public: // Not allowed: X():i(100000),s(10000) { } // Allowed void InitializeDefaults() { i = 100000; s = 10000; } private: int i;
2
by: Jack | last post by:
Hi, Performance-wise, is there a difference between these 2 clauses? I assume a large database... 1) With the WHERE clause: Select FLD1, FLD2, FLD3 From myFile Where FLD1 = 1 And FLD2 = 1
7
by: tiptap | last post by:
Hey Guys, I have a huge statement loads of if statements in... and its getting bigger. On closer inspection there is only 3 difference in the select statement. so I thought I could cut the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.