note 101984 added to function.mysql-fetch-array
| From: | AmineO at osu1 dot php dot net | Date: | Fri, 21 Jan 2011 15:49:54 +0000 |
| Subject: | note 101984 added to function.mysql-fetch-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-175967@lists.php.net to get a copy of this message | ||
If you use implode() with the return value by mysql_fetch_array, if you use MYSQL_BOTH on parameter
2, the result is not really what you're expecting.
For example :
my sql database contains "Amine, Sarah, Mohamed";
$array = mysql_fetch_array($resource,MYSQL_BOTH);
or $array = mysql_fetch_array($resource);
echo implode(" - ", $array);
the result is : Amine-Amine-Sarah-Sarah-Mohamed-Mohamed
and we expect just : Amine-Sarah-Mohamed
You must use MYSQL_NUM or MYSQL_ASSOC on parameter 2 to resolve the problem.
--------------------------------------------------------------
Si vous utilisez implode() qui prend en parametre la valeur retournée mysql_fetch_array, si vous
mettez en 2eme parametre MYSQL_BOTH (ou rien) le resultat retourné n'est pas vraiment le
resultat que vous attendez :
par exemple:
Ma sql database contient "Amine, Sarah, Mohamed";
$array = mysql_fetch_array($resource,MYSQL_BOTH);
or $array = mysql_fetch_array($resource);
echo implode(" - ", $array);
Le resultat affiché est : Amine-Amine-Sarah-Sarah-Mohamed-Mohamed
alors que nous attendons : Amine-Sarah-Mohamed
Vous devez utiliser MYSQL_NUM or MYSQL_ASSOC en 2eme parametre pour resoudre le probleme.
----
Server IP: 195.221.21.36
Probable Submitter: 89.81.148.159
----
Manual Page -- http://www.php.net/manual/en/function.mysql-fetch-array.php
Edit -- https://master.php.net/note/edit/101984
Del: integrated -- https://master.php.net/note/delete/101984/integrated
Del: useless -- https://master.php.net/note/delete/101984/useless
Del: bad code -- https://master.php.net/note/delete/101984/bad+code
Del: spam -- https://master.php.net/note/delete/101984/spam
Del: non-english -- https://master.php.net/note/delete/101984/non-english
Del: in docs -- https://master.php.net/note/delete/101984/in+docs
Del: other reasons-- https://master.php.net/note/delete/101984
Reject -- https://master.php.net/note/reject/101984
Search -- https://master.php.net/manage/user-notes.php