<?php

// Make a MySQL Connection
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("borrow") or die(mysql_error());

$TextBox1 = implode(', ', $_POST['Name']);
$TextBox6 = implode(', ', $_POST['Startdate']);
$TextBox7 = implode(', ', $_POST['Enddate']);
$TextBox8 = implode(', ', $_POST['Item1']);
$TextBox8 = implode(', ', $_POST['Item1']);
$TextBox8 = implode(', ', $_POST['Item1']);
$TextBox9 = implode(', ', $_POST['Item2']);
$TextBox9 = implode(', ', $_POST['Item2']);
$TextBox9 = implode(', ', $_POST['Item2']);
$TextBox10 = implode(', ', $_POST['Item3']);
$TextBox10 = implode(', ', $_POST['Item3']);
$TextBox10 = implode(', ', $_POST['Item3']);


if(isset($_POST['submit']))
{       
    $query="INSERT INTO epal VALUES ('" . $TextBox1 . "','" . $TextBox6 . "','" . $TextBox7 . "','" . $TextBox8 . "','" . $TextBox9 . "','" . $TextBox10 . "')";     
    mysql_query($query) or die (mysql_error() );
 echo "Complete";
}
?>

**result **

Notice: Undefined index: Item1 in C:\xampp\htdocs\borrow\borrow2.php on line 8

Warning: implode(): Invalid arguments passed in C:\xampp\htdocs\borrow\borrow2.php on line 8

**My coding don't have any problem but after i try to refresh the borrow2.php it appear this. I don't know which part is my mistake. **

This is the line 8
$TextBox6 = implode(', ', $_POST['Startdate']);

Startdate not exist in $_POST array. You dont have an input with this name attribute, verify your form which call your php code.

Member Avatar for diafol

THis is an overly complicated concatenation. You really should be using mysqli or PDO and parameterized queries.

Anyway for deprecated mysql(!):

if(isset($_POST['submit']))
{       
    mysql_connect("localhost", "root", "") or die(mysql_error());
    mysql_select_db("borrow") or die(mysql_error());

    $p = array_map("mysql_real_escape_string", $_POST);

    $query="INSERT INTO epal VALUES ('{$p['Name']}','{$p['Startdate']}','{$p['Enddate']}','{$p['Item1']}','{$p['Item2']}','{$p['Item3']}')";     
    mysql_query($query) or die (mysql_error() );
    echo "Complete";
}

Why do you repeat '$TextBox8' and 9 and 10 three times each?

I'm assuming from this table that you do not have a primary key - if you do then your first value needs to be NULL:

INSERT INTO epal VALUES (NULL, '{$p['Name']}','{$p['Startdate']}','{$p['Enddate']}','{$p['Item1']}','{$p['Item2']}','{$p['Item3']}')
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.