Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7987905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:16:54+00:00 2026-06-04T12:16:54+00:00

I am trying to learn some PHP using the book titled PHP for Absolute

  • 0

I am trying to learn some PHP using the book titled PHP for Absolute Beginners. I am trying to implement some blog design code given in the book using WAMP and editplus. When I try to insert the data using PHP form, all I get is NULL values in the database table. Here is a piece of code for inserting values into the DB.

<?php
if($_SERVER['REQUEST_METHOD']=='POST'
&& $_POST['submit']=='Save Entry'
&& !empty($_POST['title'])
&& !empty($_POST['entry']))
{
// Include database credentials and connect to the database
include_once 'db.inc.php';
$db = new PDO(DB_INFO, DB_USER, DB_PASS);

// Save the entry into the database
$sql = "INSERT INTO entries (title, entry) VALUES (?, ?)";
$stmt = $db->prepare($sql);
$stmt->execute(array($title, $entry));
$stmt->closeCursor();

// Get the ID of the entry we just saved
$id_obj = $db->query("SELECT LAST_INSERT_ID()");
$id = $id_obj->fetch();
$id_obj->closeCursor();

// Send the user to the new entry
header('Location: ../admin.php?id='.$id[0]);
exit;
}
// If both conditions aren't met, sends the user back to the main page
else
{
header('Location: ../admin.php');
exit;
}
?>

When I check the apache error log I see this:

[Sun May 27 19:21:24 2012] [error] [client 127.0.0.1] PHP Notice:  Undefined 
variable: title in C:\\wamp\\www\\examples\\simple_blog\\inc\\update.inc.php
on line 14, referer: http://localhost/examples/simple_blog/admin.php?id=8
[Sun May 27 19:21:24 2012] [error] [client 127.0.0.1] PHP Stack trace:, referer: 
http://localhost/examples/simple_blog/admin.php?id=8
[Sun May 27 19:21:24 2012] [error] [client 127.0.0.1] PHP   1. {main}() 
C:\\wamp\\www\\examples\\simple_blog\\inc\\update.inc.php:0, referer:    
http://localhost/examples/simple_blog/admin.php?id=8
[Sun May 27 19:21:24 2012] [error] [client 127.0.0.1] PHP Notice:  Undefined 
variable: entry in C:\\wamp\\www\\examples\\simple_blog\\inc\\update.inc.php 
on line 14, referer: http://localhost/examples/simple_blog/admin.php?id=8
[Sun May 27 19:21:24 2012] [error] [client 127.0.0.1] PHP Stack trace:, referer: 
http://localhost/examples/simple_blog/admin.php?id=8
[Sun May 27 19:21:24 2012] [error] [client 127.0.0.1] PHP   1. {main}() 
C:\\wamp\\www\\examples\\simple_blog\\inc\\update.inc.php:0, referer: 
http://localhost/examples/simple_blog/admin.php?id=8

I don’t know what these errors are. Please help me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T12:16:57+00:00Added an answer on June 4, 2026 at 12:16 pm

    Possibly your server is configured so that $_POST['title'] is not automatically aliased as $title. Initialize $title = $_POST['title'] and same for other used $_POST items manually.

    <?php
    if($_SERVER['REQUEST_METHOD']=='POST'
    && $_POST['submit']=='Save Entry'
    && !empty($_POST['title'])
    && !empty($_POST['entry']))
    {
        $title = $_POST['title'];
        $entry = $_POST['entry'];
    
    ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing in C++ and is trying to learn some php. I was
I'm trying to learn php and step one is getting php working in some
I'm trying to learn Symfony that requires using php in the command line /
I've trying to learn PHP OOP and have made some research on how to
I'm trying to learn some PHP, and I've been banging my head against this
Im trying to learn php by doing a little project using apache server. I
I am trying to learn OOP in PHP, and I have some confusion about
I am trying to learn using DOMDocument for parsing HTML code. I am just
I am new to PHP and trying to learn some so sorry if this
I am trying to learn oop in php, but the below code is not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.