I'm at best a hobbyist who is just now bringing to use PDO and i'm have a heck of a time with insert statements. I have a function which is meant to update several columns in a table but my data does not seem to be binding correctly? I've looked over google, php.net, http://wiki.hashphp.org, stack overflow itself, and the sql site, but i've not found a solid example i can draw an apples to apples comparison too on how to do this. I've seen lots of examples where they update a single column, but none showing how to update a couple columns and i'm just not able to figure it out.
hopefully someone out there can help me and my flu soaked brain figure this out.
MY GITHUB: https://github.com/monkeework/WrDK My SCRIPT: https://github.com/monkeework/WrDK/blob/master/library/timeline.php
MY FUNCTION:
function timelineRevise(){
#TimelineID & EntryID passed as hidden post values from timelineEdit() function
/*
<input type="hidden" name="EntryID" value="' . dbOut($row['TimelineID']) . '" />
<input type="hidden" name="EntryID" value="' . dbOut($row['EntryID']) . '" />
*/
$TimelineID = strip_tags($_POST['TimelineID']); #int - primaryKey
$EntryID = strip_tags($_POST['EntryID']); #int
$EntryTitle = strip_tags($_POST['EntryTitle']); #str
$EntryDate = strip_tags($_POST['EntryDate']); #str - entered by user
$EntryDescription = strip_tags($_POST['EntryDescription']); #str
$CharTag = strip_tags($_POST['CharTag']); #str of comma sep numbers
$db = pdo(); # pdo() creates and returns a PDO object
//dumpDie($FirstName);
$sql = "
UPDATE ma_Timeline
SET
TimelineID = :timeline_id, #PrimeKey
EntryID = :entry_id,
EntryTitle = :entry_title,
EntryDate = :entry_date,
EntryDescription = :entry_desc,
CharTag = :char_tag
WHERE EntryID = :entry_id";
$stmt = $db->prepare($sql);
//The Primary Key of the row that we want to update.
$stmt->bindValue(':timeline_id', $TimelineID, PDO::PARAM_STR); #INT - PrimeKey
$stmt->bindValue(':EntryID', $EntryID, PDO::PARAM_INT);
$stmt->bindValue(':entry_title', $EntryTitle, PDO::PARAM_STR);
$stmt->bindValue(':entry_date', $EntryDate, PDO::PARAM_STR);
$stmt->bindValue(':entry_desc', $EntryDescription, PDO::PARAM_STR);
$stmt->bindValue(':char_tag', $CharTag, PDO::PARAM_STR);
//INTEGER EXAMPLE $stmt->bindValue(1, $id, PDO::PARAM_INT);
try {$stmt->execute();} catch(PDOException $ex) {trigger_error($ex->getMessage(), E_USER_ERROR);}
#feedback success or failure of update
if ($stmt->rowCount() > 0)
{//success! provide feedback, chance to change another!
feedback("Event Revised Successfully!","success");
}else{//Problem! Provide feedback!
feedback("Event NOT REVISED!","warning");
}
myRedirect(THIS_PAGE);
}