Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2009
    Posts
    3

    Unanswered: Error from error_log

    Hi

    Yesterday I saw my error_log and was very astonished. There were more than 10000 errors, and only this:

    [18-Mar-2009 02:03:55] WordPress database error 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 'AND taxonomy = 'category'' at line 1 for query SELECT * FROM wp_term_taxonomy WHERE term_taxonomy_id = AND taxonomy = 'category' made by require, require_once, include, include
    Does anyone know what it means? It's a wordpress database.

    Thanks

  2. #2
    Join Date
    Sep 2002
    Location
    Ohio
    Posts
    204
    I know nothing of Wordpress, but look at the following SQL statement from your error log and tell me what is wrong with it:

    Code:
    SELECT * 
    FROM wp_term_taxonomy 
    WHERE term_taxonomy_id = 
    AND taxonomy = 'category'

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    yes, it means there's a syntax error in your query

    let me revise your query slightly to be more readable...
    Code:
    SELECT * 
      FROM wp_term_taxonomy 
     WHERE term_taxonomy_id = 
       AND taxonomy = 'category'
    can you spot the error now?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    argghh, sniped again!!! by a full two minutes!!

    nice one, buckeye

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Mar 2009
    Posts
    3
    As I guess you're about the empty value after term_taxonomy_id, is that right?

  6. #6
    Join Date
    Sep 2002
    Location
    Ohio
    Posts
    204
    Quote Originally Posted by levani
    As I guess you're about the empty value after term_taxonomy_id, is that right?
    Correct! Someone, or something, must be repeatedly submmitting this improper query. Your job, should you decide to accept it, is to find the cause of this massively annoying error message and stamp it out.

    This post will self destruct in 30 seconds.

  7. #7
    Join Date
    Mar 2009
    Posts
    3
    This is the code which gets data from database:

    $mtladmtavari = $wpdb->get_row("SELECT * FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = $araperi AND taxonomy = 'category' ");
    As you see there is $araperi variable after term_taxonomy_id and it seems this variable doesn't always have any value.

    Will this code prevent database query if the $araperi variable is empty?

    <?php
    if ( $araperi != NULL ) {
    $mtladmtavari = $wpdb->get_row("SELECT * FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = $araperi AND taxonomy = 'category' ");
    } ?>
    Have you got any better ideas?

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •