php - PDO Insert Query Not Working For Integer -


i have code insert new row mysql db using pdo:

$query = insert asset_positions (pos_asset_id, pos_latitude, pos_longitude, pos_timestamp) values (:pos_asset_id, :pos_latitude, :pos_longitude, :pos_timestamp) $statement = $pdo->prepare($query); $array = [':pos_asset_id' => 1, ':pos_latitude' => -8.5, ':pos_longitude' => 125.5, ':pos_timestamp' => 1398160487]; $statement->execute($array); echo $pdo->lastinsertid(); 

the query runs without error shown. newly inserted row id echoed. however, when in db, insert latitude, longitude , timestamp. pos_asset_id field in newly inserted row empty.

could point out problem? there no error message displayed. i've been trying solve hours without avail.

ps. first time using pdo, please bear me. thanks.

edit

solved! didn't notice there's fk relation between asset_positions.pos_asset_id , asset.asset_id. once remove relationship constrains, insert works now, pos_asset_id value inserted record.

anyway, all! :)

try running error catching, give better understanding of happening.

try {    $stmt->execute(); } catch (pdoexception $p) {     echo $p->getmessage(); } catch (exception $e) {     echo $e->getmessage(); } 

but common sense , user3540050 right... it's column related issue probably


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -