Skip to:
Content
Pages
Categories
Search
Top
Bottom

database writing not working within user profiles?

  • Avatar of firetag
    firetag
    Participant

    @firetag

    Ok so I’ve been working on a plugin for a long time and I have come across one bug that I just cannot fix…. here is the code can anyone point out anything wrong? I have narrowed it down to the sql in the else clause so I do believe the sql is being run it’s just that it is returning false for whatever reason…

    Code (what are the code tags again?):

    function save() {
    global $wpdb, $bp;

    if ( $this->id ) {
    // Update
    $sql = $wpdb->prepare(
    “UPDATE {$bp->mlgfantasy->player_table} SET
    team =%s,
    player =%s,
    kills =%d,
    deaths =%d,
    assists =%d,
    time =%d,
    games =%d
    WHERE id = $this->id”,
    $this->team,
    $this->player,
    $this->kills,
    $this->deaths,
    $this->assists,
    $this->time,
    $this->games
    );
    } else {
    // Save
    $sql = $wpdb->prepare(
    “INSERT INTO {$bp->mlgfantasy->player_table} (
    team,
    player,
    kills,
    deaths,
    assists,
    time,
    games
    ) VALUES (
    %s, %s, %d, %d, %d, %d, %d
    )”,
    $this->team,
    $this->player,
    $this->kills,
    $this->deaths,
    $this->assists,
    $this->time,
    $this->games
    );
    }
    $result = $wpdb->query($sql);
    if ( !$result )
    return $result;

    if ( !$this->id ) {
    $this->id = $wpdb->insert_id;
    }

    return $result;
    }

You must be logged in to reply to this topic.