I'm rebuilding my current script to support PDO instead of MySQL queries. I am stuck on this insert query though, it's not executing and I have no clue why.
Google'd around a bit but couldn't find anything.
try
{
$sql = "INSERT INTO
news (news_name,
news_description,
news_author,
news_date,
news_link,
news_category)
VALUES ('" . trim($_POST['news_name']) . "',
'" . trim($_POST['news_description']) . "',
" . $_SESSION['admin_id'] . ",
NOW(),
'" . trim($_POST['news_link']) . "',
'" . trim($_POST['news_category']) . "'
)";
$results = $db->exec($sql);
$id = $db->lastInsertId();
if($results)
{
echo $id;
echo '<p>News item added succesfully</p>';
echo '<a href="admin.php">Click here to return to the admin panel</a>';
}
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
?>