// 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
	  //undefined index: login
if (isset($_SESSION['login'])){
		echo "Anda tidak berhak mengakses halaman ini.";

	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());
			$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.

6 Years
Discussion Span
Last Post by raj2719

There is no need to mention the values like ".$kategori." You just declare it as
mysql_query(insert into kategori_berita vaules('$$kategori'); if it is a string if not so just remove quotes.
And you didn't used query so the server will not understand which query should be executed please try the above syntax.


I suppose you are misspelled the form fields "kategori","id".
Check out your previous page for correct spelling.

It is clear , if you post the previous page code.


I wonder why in my category box is written:

<br /><b>Notice</b>: Undefined variable: kategori in <b>C:\xampp\htdocs\php_template2\category_manager.php</b> on line <b>122</b><br />
Kategory [_______________]

line 122: <input name="kategori" type="text" id="kategori" value="<?php echo $kategori;?>"/>

Edited by davy_yg: n/a


This has been described in your other post. $_REQUEST['kategori'] may not have a value, use isset() . Also, $_REQUEST is deprecated, use $_GET

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.