// connect to database
$con = mysql_connect('localhost', 'root', '');
if (!$con) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
$db_selected = mysql_select_db("template", $con);
if (!$db_selected)
{
die ("Can't use template : " . mysql_error());
}
// cek login
session_start();
//undefined index: login
if (isset($_SESSION['login'])){
echo "Anda tidak berhak mengakses halaman ini.";
exit();
}
//SIMPAN DATA
if (isset($_REQUEST['simpan'])){
$kategori = mysql_real_escape_string($_REQUEST['kategori']);
$id = $_REQUEST['id'];
if (empty($id))
$sqlstr = "INSERT INTO kategori_berita VALUES('".$kategori."')" or die(mysql_error());
else
$sqlstr = "UPDATE kategori_berita SET kategori = '".$kategori."' WHERE id =".$id;
These are the errors:
Connected successfully
Notice: Undefined index: kategori in C:\xampp\htdocs\php_template2\category_manager.php on line 97
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=
Notice: Undefined variable: id in C:\xampp\htdocs\php_templa' at line 1
Line 97: $kategori = mysql_real_escape_string($_REQUEST);
What's wrong with these errors: I am trying to save information and would like to see it
in table, yet the error appears and the saved information does not appears on the table.