i have been using this code in creating blog
i'm getting this error on exectute(array($title,$entry); line
the error is

Notice: Undefined variable: title in D:\xampp\htdocs\simple_blog\inc\update.inc.php on line 14

Notice: Undefined variable: entry in D:\xampp\htdocs\simple_blog\inc\update.inc.php on line 14

can any one please help me out.

<?php
if($_SERVER['REQUEST_METHOD']=='POST'

    && $_POST['submit'] =='Save Entry'  
    && !empty($_POST['title'])
    && !empty($_POST['entry'])      

        )
{
    include_once 'db.inc.php';
    $db= new PDO(DB_INFO,DB_USER,DB_PASS);
    $sql="INSERT INTO entries (title,entry) VALUES(?,?)";
    $stmt= $db->prepare($sql);
    $stmt->execute(array($title,$entry));
    $stmt->closeCursor();   

}
else
{
    header('Location: ../admin.php');
    exit;
}

Recommended Answers

All 2 Replies

Variables $title and $entry haven't been defined anywhere in the script. Did you forget to add these two lines:

$title = $_POST['title'];
$entry = $_POST['entry'];
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.