I encountered a php error that I can't seem to fix and I can't even find the problem for. When the browser gets to a certain point on the php page, it gives this error: "Error fetching article details: You have an error in your SQL syntax near 'AND CID=1' at line 1". I double spaced the line that the error is refering to.

Now here is the whole area of the php script that the error was located in. Everything else on the page works fine.

while ($cat = mysql_fetch_array($cats)) {
$cid = $cat["ID"];
$cname = $cat["Name"];

// Check if the joke is in this category
$result = mysql_query(
"SELECT * FROM ArticleLookup " .

"WHERE AID=$id AND CID=$cid");

if (!$result) {
echo("<P>Error fetching article details: " .
mysql_error() . "</P>");

// mysql_num_rows gives the number of entries
// in a result set. In this case, if the result
// contains one or more rows, the condition
// below will evaluate to true to indicate that
// the joke does belong to the category, and the
// checkbox should be checked.
if (mysql_num_rows($result)) {
echo("<INPUT TYPE=CHECKBOX CHECKED NAME='cat$cid'>$cname<BR>\n");
} else {
echo("<INPUT TYPE=CHECKBOX NAME='cat$cid'>$cname<BR>\n");


Chris Roane

Web Services: DevStorm | Intersurge
Web Tools: Web Site Resource | Free Web Site Tools