php - PDO not inserting into database but has correct values -


i trying create basic blog , i've followed syntax of previous project insert mysql database not add. echo'd values see if passing correctly , when check database nothing added. there wrong can see code? thank in advance answers regardless if able or not.

edit: checked database , working correctly , named, connect.php works login since information same should work here.

edit2: database table follows

postid int(10) auto_increment   title    text  author   text  date     date  content  text  tag1     text  tag2     text 

<?php  // make sure user logged in session_name('blog'); session_start(); if (empty($_session['username'])) {     header("location: loginhome.php");     exit; }  // connect database , add message include("connect.php");   $one = $_post['title']; $two = $_post['author']; $three = $_post['content']; $four = $_post['cat1']; $five = $_post['cat2']; echo $two;   $add_message_query = $db->prepare("     insert `blogposts`         (`title`, `author`, `date`, `content`, `tag1`, `tag2`)     values         (:title, :author, current_timestamp, :content, :cat1, :cat2)     ");  $add_message_query->execute(     array(     ':author' => $one,     ':title' => $two,     ':content' => $three,     ':cat1' => $four,     ':cat2' => $five     ) ); //go home show new post //header("location: home.php"); ?>    

please, use $db->setattribute(pdo::attr_errmode, pdo::errmode_exception); better error handling.

http://www.php.net/manual/en/pdo.setattribute.php


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -