|
Posted by Norman Peelman on 05/19/07 18:21
Akhenaten wrote:
> Somehow hours of typing have blinded me. Basically I'm trying to come
> up with an "If not this then this" type scenario but (as you can
> probably see) I am not getting what I want. All variables are good
> (queries, etc.)
>
> I want either "CANT GO HERE" or "GO HERE" but instead I end up with
>
> "CAN'T GO HERE"
> "GO HERE"
> "GO HERE"
> "GO HERE"
>
> Of course I know the while loop is giving me the reiterations but I'm
> not sure why I'm getting both sets back instead of one. Thoughts
> [other than giving up PHP] ??
>
>
>
> ***************************
> // This Function is KILLING ME
> function didi_answer($qid,$userid)
> {
> include "db.inc.php";
> $qstatus = mysql_query("SELECT status FROM `questions` WHERE `qid` =
> '$qid'", $db);
> $query1 = mysql_fetch_array($qstatus);
> // Query 2 and 1
> $result = "SELECT `a_uid` FROM `answers` WHERE `qid` = '$qid'";
> $query = mysql_query($result, $db);
> while ($item = mysql_fetch_array($query)) {
> if (in_array($userid,$item)) {
> echo "<br><br>CANT GO HERE";
> }
> if ( $query1['status'] = '1'){
> echo "<br><br><a href='apage.php?qid=$qid'>GO HERE</a>";
> }
> }
>
> ************************
>
You are getting two sets of data returned for each query.
mysql_fetch_array(...) returns an array consisting both ASSOCIATIVE and
NUMERIC keys. Change to:
mysql_fetch_array($qstatus,MYSQL_ASSOC);
valid options are MYSQL_ASSOC, MYSQL_NUM, and MYSQL_BOTH
default = MYSQL_BOTH
also
mysql_fetch_assoc($qstatus); // for associative keys only
Norm
[Back to original message]
|