in reply to Unexplained MySQL Error

How are you building and executing the query in your script?

After running a few possible permutations of your query, it seems to be that you're attempting the following query:

select parent from categories where id=

Again, check how you are building the query. You aren't using placeholders since doing that would evaluate as id=NULL and properly execute (albeit, not with the results for which you were looking).

Hope this helps.

antirice    
The first rule of Perl club is - use Perl
The
ith rule of Perl club is - follow rule i - 1 for i > 1