Forum Moderators: coopster
try
{
$allowedTags='<p><strong><em><u><h1><h2><h3><h4><h5><h6><img>';
$allowedTags.='<li><ol><ul><span><div><br><ins><del>';
$news_id = 12;
$news_title = trim(stripslashes($_POST['news_title']));
$news_item = strip_tags(stripslashes($_POST['elm1']), $allowedTags);
$db_host = $config['db_host'];
$db_database = $config['db_database'];
$db_username = $config['db_username'];
$db_password = $config['db_password'];
$dbh = new PDO("mysql:host=$db_host;dbname=$db_database", "$db_username", "$db_password");
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $dbh->prepare("UPDATE tbl_news SET title=?, body=? WHERE id=?");
$stmt->bindParam(1, $news_title);
$stmt->bindParam(2, $news_item);
$stmt->bindParam(3, $news_id);
$result = $stmt->execute();
if ($result)
{
echo 'record updated successfully';
}
else
{
echo 'record not updated';
}
}
catch(PDOException $e)
{
echo '<h4>'.$e->getMessage().'</h4>';
}
catch(Exception $e)
{
echo '<h4>'.$e->getMessage().'</h4>';
}