I got a problem when inserting a data. When I click the add button this are always comes out “Error Sir” which is this one die ('Error Sir' . mysql_error()).
But when I tried to look for my database everything what I inserted was there.
<?php
error_reporting (E_ALL ^ E_NOTICE);
$add = $_POST['add']; //Add button
$date = $_POST['date'];
$project = $_POST['project'];
$task = $_POST['task'];
$originated = $_POST['originated'];
$incharge = $_POST['incharge'];
$deadline = $_POST['deadline'];
$status = $_POST['status'];
$comment = $_POST['comment'];
$fin = $_POST['fin'];
//If add button click
if ($add)
{
//This is for checkbox group
if(is_array($incharge))
{
foreach($incharge as $val2)
{
$tstring = implode(', ' , $incharge);
//Database Connection
$con = mysql_connect ("localhost","root","");
if (!$con)
{
die ('Not connected to DB' . mysql_error());
}
//Selecting Database
mysql_select_db ("profound_master", $con);
//Adding of data to te Database
$sql = "INSERT INTO bulletin VALUES ('','$date','$project','$task','$originated','$tstring','$deadline','$status','$comment','$fin')";
if (!mysql_query ($sql, $con));
{
die ('Error Sir' . mysql_error()); //Always stop here
}
echo "1 record added";
mysql_close($con);
}
}
}
?>
As others suggested, try to find out the error you are getting before anything else. Also make sure the data you have in the database is actually the data you are currently inserting. I’m almost sure you have the same data already in the database and you THINK you are inserting new values.