0
// 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.

Edited by davy_yg: n/a

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by urtrivedi
0

I think problem is in the page which is calling this page and not on this page.
Check the spelling of your form elements in previous form.

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.