2014-02-18

I want to update my data, so I have this code

update2.php

Expand|Select|Wrap|Line Numbers

<?php

 

$name = $_POST['name'];

$id = $_POST['id'];

//$tarikh = $_POST['tarikh'];

$tindakan = $_POST['tindakan'];

$agihan = $_POST['agihan'];

 

$connection = mysql_connect("localhost","root","") or die ("Could Not Connect To Server".mysql_error());

$selection = mysql_select_db("permohonan_data") or die ("Could Not Connect To Database".mysql_error());

 

//$sql= "UPDATE pemohon SET tarikh='$tarikh', tindakan='$tindakan', agihan='$agihan', WHERE id='$noid'";

$sql= "UPDATE pemohon SET tindakan='$tindakan', agihan='$agihan', WHERE id='$id'";

$result = mysql_query($sql) or die (mysql_error());

 

if($result)

{   

?>

    <script language="javascript">

    alert("Permohonan <?php echo "$name"; ?> telah dikemaskini");

    location.href="admin.php";

    </script>

 

<?php

}

 

?>

but it turned out to be errors which I didn't know what to do. please help me

this is the errors,

Expand|Select|Wrap|Line Numbers

Undefined index: id in C:\wamp\www\FORM\update2.php on line 4

Expand|Select|Wrap|Line Numbers

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 'WHERE id=''' at line 1

Show more