0

I have the following codes:

$confirmation = ($result)? "Data telah terhapus.":"Gagal menghapus data.";
		}elseif ($_REQUEST['mode'] == 'edit'){
			$result = mysql_query("SELECT * FROM kategori_berita WHERE id=".$_REQUEST['id']) or die(mysql_error());
			$data = mysql_fetch_array($result);
			$id = $data['id'];
			$kategori = $data['kategori'];
		}
	}
	?>
<div align="center">
	<div style="width:700px;text-align:left;padding-top:25px;">
	<div class="pageTitle">Category Manager</div>
	<?php echo $confirmation; ?><br/>
	<form method="get" action="<?php $_SERVER['PHP_SELF'] ?>">

This error appears:

Category Manager

Notice: Undefined variable: confirmation in C:\xampp\htdocs\php_template2\category_manager.php on line 109


Line 109 is <?php echo $confirmation; ?><br/>

What's wrong with it? I thought I define it already.

4
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by cwarn23
0
$confirmation = ($result)? "Data telah terhapus.":"Gagal menghapus data.";

You are setting confirmation in if condition so it is giving warning when you tried to used unintialise variable.

so before your if statement you write

$confirmation="";
0
<?php if($confirmation != '' || $confirmation != null) : ?>
<?php echo $confirmation; ?><br/>
<?php endif; ?>

You can try like above perhaps.

0

The more recourse efficient method would be to use the following on line 109.

<?php echo (!isset($confirmation))?$confirmation='':$confirmation; ?><br/>
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.