Re: Queries and Arrays
| From: | Cynic | Date: | Wed, 27 Dec 2000 06:27:06 +0000 |
| Subject: | Re: Queries and Arrays | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-31925@lists.php.net to get a copy of this message | ||
you can either use
... AND (uid = '" . $SESSION["p101"] . "' OR ...
or
... AND (uid = '{$SESSION["p101"]}' OR ...
though in the latter you might need to escape the double quotes in
the array offset like so:
... AND (uid = '{$SESSION[\"p101\"]}' OR ...
At 07:20 27.12. 2000, RealGM Webmaster wrote the following:
--------------------------------------------------------------
>Hi,
>
>I have a little question. I have an array that contains 25 values, and I need to compare each
>value to another value within a query. Previously I had 25 different variables and compared each
>individually, but then with more and more users using our system my session management was not
>working correctly so I was forced to change. Now, with the new change, I am getting the following
>error message:
>
> Parse error: parse error, expecting
T_STRING' or ¡ˆsªþþdÈÕýã
> 5{T_VARIABLE' or `T_NUM_STRING'
>
>My query looks like the following:
>
>$result = mysql_query("SELECT * FROM data WHERE user = '$user' AND (uid =
>'$SESSION["p101"]' OR uid = '$SESSION["p102"]' OR uid =
>'$SESSION["p103"]' OR uid = '$SESSION["p104"]' OR uid =
>'$SESSION["p105"]' OR uid = '$SESSION["p106"]' OR uid =
>'$SESSION["p107"]' OR uid = '$SESSION["p108"]' OR uid =
>'$SESSION["p109"]' OR uid = '$SESSION["p110"]' OR uid =
>'$SESSION["p111"]' OR uid = '$SESSION["p112"]' OR uid =
>'$SESSION["p113"]' OR uid = '$SESSION["p114"]' OR uid =
>'$SESSION["p115"]' OR uid = '$SESSION["p116"]' OR uid =
>'$SESSION["p117"]' OR uid = '$SESSION["p118"]' OR uid =
>'$SESSION["p119"]' OR uid = '$SESSION["p120"]' OR uid =
>'$SESSION["p121"]' OR uid = '$SESSION["p122"]' OR uid =
>'$SESSION["p123"]' OR uid = '$SESSION["p124"]' OR uid =
>'$SESSION["p125') ORDER BY y1 DESC, lastname");
>
>It is very long and tedious, and the problem lies in the calls to the array values $SESSION.
>Does anyone know if you can use an array in this manner, or so I have to convert each array value
>into a stand alone variable then compare from here?
>
>Thanks,
>Michael.
------end of quote------
____________________________________________________________
Cynic:
A member of a group of ancient Greek philosophers who taught
that virtue constitutes happiness and that self control is
the essential part of virtue.
cynic@mail.cz