-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Maybe this will help:
Break the query up into a variable so PHP can string it together
better.
Exec. the query, check the result, if good,
check the results for rows, if results, display results,
else, do nothing, if query faield, set err to 1 and set
an error message.



mysql_select_db("centraldb",$db);
$qorder++; 
$query="SELECT q.questid, q.question, q.answer, q.qorder, q.depart,
q.catid, "
        ."q.active, q.global, q.adate, q.author, q.authoremail, q.askemail,
        ."c.catid, c.category, c.under, c.corder, c.active "
        ." FROM central_groupfaqq q, central_groupfaqcat c "
        ."WHERE q.active = '1' AND q.global = '1' AND c.active = '1' "
        ."ORDER BY c.under, c.order, q.qorder;"
;
if($result=mysql_query($query)) {
        if($num=mysql_num_ros($result)) {
                while ($myrow = mysql_fetch_row($result))
                        //display resutls
                }
        } else {
                //no results
        }
} else {
        //bad query
        $err=1
        $errMsg="Failed Query: $query<br>".mysql_errno()." :
".mysql_error();
}


<---somehwere in html file---->

if(!$err) {
        //display results and info here
} else {
        printf("%s\n",$errMsg);
}



- ---------------------
Johnny Withers
[EMAIL PROTECTED]
p. 601.853.0211
c. 601.954.9133
 


- -----Original Message-----
From: Keith Spiller [mailto:[EMAIL PROTECTED]]
Sent: Sunday, February 25, 2001 2:30 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Join causing Error?


Can anyone tell me why this:
  Line 282    mysql_select_db("centraldb",$db);
  Line 283    $qorder++; 
  Line 284    $result = mysql_query("SELECT q.questid, q.question,
q.answer, q.qorder, q.depart, q.catid, 
                  q.active, q.global, q.adate, q.author,
q.authoremail, q.askemail, c.catid, c.category, c.under, 
                  c.corder, c.active FROM central_groupfaqq q,
central_groupfaqcat c WHERE q.active = '1' AND 
                  q.global = '1' AND c.active = '1' ORDER BY c.under,
c.order, q.qorder",$db);
  Line 285    while ($myrow = mysql_fetch_row($result))

Would cause this error:
  Warning: Supplied argument is not a valid MySQL result resource in
faqbody.php3 on line 285

When changing the same SELECT statement to:
  Line 284    $result = mysql_query("SELECT * FROM central_groupfaqq
WHERE active = '1' ORDER BY
                   qorder",$db);

Works perfectly?


Keith Spiller
a.k.a. Larentium


-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 6.5.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBOpppHLFNxPoD98ryEQL95QCffp7UNf0lJdx0lwSUjFdRKRths94AoIsS
4fpFCCXraXVYdkR2Hg5mKd0P
=vlca
-----END PGP SIGNATURE-----


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to