• Resolved islandcastaway

    (@islandcastaway)


    Can someone please help me with this sql query:

    $image = $wpdb->get_var($wpdb->prepare("SELECT image FROM $wpdb->wordtube WHERE vid = $wordtubeId"));

    I am getting this error:

    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 '' at line 1 for query SELECT image FROM wordtube WHERE vid = made by require, require_once, include, boposts_show

    The query is working but I get this in php-errors.log

    What am I missing?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Probably too late for this one but have you tried WHERE vid = ‘$wordtubeId'”));?

    Thread Starter islandcastaway

    (@islandcastaway)

    RE: alxvallejo wrote:

    Probably too late for this one but have you tried WHERE vid = ‘$wordtubeId'”));?

    I thought that I posted my fix, guess not, and not sure why @alxvallejo post isn’t here I just got via email subscription.

    Newayz I got it fixed with

    $image = $wpdb->get_var(“SELECT image FROM ($wpdb->wordtube) WHERE vid = ($wordtubeId)”);}

    Cheers

    Just curious, were you placing this inside a function? I’m fairly new at plugin development and I’m trying to figure out if I’m inserting variables correctly.

    Thread Starter islandcastaway

    (@islandcastaway)

    Yes.

    To be specific I added it to the plugin “best related posts” to grab the thumbnail from a post that had “wordtube” content.

    I have no clue if my code is 100% correct, but its working and it doesn’t throw any errors.

    Cheers

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘sql query help’ is closed to new replies.