• hi there,

    Im working on a small plugin and want to buildin a function to truncate it’s table.

    Currently im struggling with this code:

    if($user_level >= 10) {
    $deletequery = "TRUNCATE TABLE ".$table_prefix."winamp";
    if(!$wpdb->query($deletequery)) {
    die(mysql_error());
    } else {
    header('Location: options-general.php?page=wp_winamp/wp-winamp.php&cleared=true');
    }
    }

    But somehow this always results in a error.
    I did not manage to get mysql_error() to output something i guess it gets somewhere outputted before i call it and therefor cannot see it.

    When i add echo 'error'; above the line where die() is in. I get error. So something is wrong.

    When i replace the wordpress query function for mysql_query() it does work with no trouble.

    I wordpress limited in its use of Truncate? I always thought i could feed it any query i like.

    Many thanks!

  • The topic ‘Truncating a table’ is closed to new replies.