mysql_query有效但错误检查会返回错误

This code works and enters all of the correct information into the database but the error check returns an error. I could remove the error check but I'm afraid of creating some nightmare that comes back to haunt me later or that I'm missing a fundamental issue:

    $sql5a = mysql_query("SELECT id FROM categories WHERE category='$category'");
        $categoryresult = mysql_fetch_array($sql5a);
        $oldcategoryid = $categoryresult['id'];
        $sql6a = "INSERT INTO lookupcategory SET
        fbid='$fbid2',
        categoryid='$oldcategoryid'";
            if ( @mysql_query($sql5b) ) { 
                                echo('sql5b updated successfully<br>'); 
                            } else { 
                                echo('Error: sql5b not updated<br>'.mysql_error() );
                        }
                            if ( @mysql_query($sql6b) ) { 
                                echo('sql6b updated successfully<br>'); 
                            } else { 
                                echo('Error: sql6b not updated<br>'.mysql_error() );
                        }

The output is: "Error: sql5b not updated You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #7' at line 1" "sql6b updated successfully"

When I check the database all entries are correct. If sql5a didn't work, sql6b couldn't work, hence my confusion over the error.

A sample Category would be: Travel/Leisure The category was originally created from a form response: $category = htmlentities($fbdetail['category'], ENT_QUOTES); and entered into the database successfully. An id number was assigned using AUTO_INCREMENT.

You assign query to variable $sql5a, but call @mysql_query($sql5b). $sql5b doesn't exist (at least in this sample). Same with $sql6a...

You can use INSERT syntax without VALUES, but you need to ommit INTO keyword.

$sql5a = mysql_query("SELECT id FROM categories WHERE category='$category'");
if ( $res5a = @mysql_query($sql5a) ) { // first execute query and store resource in variable
    echo('sql5a selected successfully<br>'); 
} else { 
    echo('Error: sql5a failed<br>'.mysql_error() );
}
$categoryresult = mysql_fetch_array($res5a); // fetch array passing the RESOURCE var, NOT query string
$oldcategoryid = $categoryresult['id'];
$sql6a = "INSERT lookupcategory SET
fbid='$fbid2',
categoryid='$oldcategoryid'";

if ( @mysql_query($sql6a) ) { 
    echo('sql6a inserted successfully<br>'); 
} else { 
    echo('Error: sql6a failed<br>'.mysql_error() );
}

I don't know where you get $fbid2 or $category from, since it's not in this piece of code.

The syntax for the insert is :

INSERT INTO table(col1, col2 ...) VALUES(val1, val2 ...)

In your specific case:

$sql6a = "INSERT INTO table(fbid, categoryid) VALUES('{$fbid2}','{$oldcategoryid}')"