C. Finke
C. Finke

Reputation: 129

PHP writing wrong value into DB?

I created the following table inside a DB

$sql = "CREATE TABLE tac_flightsize
(
    id int NOT NULL AUTO_INCREMENT,
    PRIMARY KEY (id),

    gameid int NOT NULL,
    shipid int,
    flightsize int
 )";

I check for a DB write like this:

if (!$ship->superheavy){
   debug::log("db flight: " + $ship->flightSize);
   self::$dbManager->submitFlightSize($id, $gamedata->id, $ship->id, $ship->flightSize);
}

The debug::log entry shows 12 as the $ship->flightSize so the value is correct.

Here is the actual submitFlightSize function:

public function submitFlightSize($shipid, $gameid, $flightSize){
        try{
            $sql = "INSERT INTO `B5CGM`.`tac_flightsize` VALUES(null, $gameid, $shipid, $flightSize)";
            $id = $this->insert($sql);
            Debug::log($sql);

        }catch(Exception $e) {
            $this->endTransaction(true);
            throw $e;
        }
}

The Debug:::log from this function shows the follow SQL entry

INSERT INTO `B5CGM`.`tac_flightsize` VALUES(null, 2535, 16238, 1) 

Now, the last parameter is 1, when it should be 12 and was a second ago according to the earlier debug.

Can anyone explain to me what i might be doing wrong ?

Upvotes: 0

Views: 45

Answers (1)

Droid
Droid

Reputation: 569

here you send 4 params

self::$dbManager->submitFlightSize($id, $gamedata->id, $ship->id, $ship->flightSize);

but function accepts only 3

public function submitFlightSize($shipid, $gameid, $flightSize)

Upvotes: 4

Related Questions