Can someone help me to fix this problemmm pleasee.

Notice: Undefined index: id in C:\xampp\htdocs\draft3\Edit.php on line 4

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\draft3\Edit.php on line 6

Edit.php

<?php include'e.php';
    if(!isset($_POST['submit']))
    {
        $q="SELECT * FROM myaduan WHERE id= $_GET[id]";
        $result=mysql_query($q);
        $myaduan=mysql_fetch_array($result);
    }
?>

<h1>You are Modifying A user</h1>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
Name<input type="text" name="inputName" value="<?php echo $myaduan['nama_pengadu'];?>"></br>
Complaints<input type="text" name="inputDesc" value="<?php echo $myaduan['aduan_details'];?>"/>
<br/>
<input type="hidden" name="id"  value="<?php echo $_GET['id'];?>">
<input type="submit" name="submit" value="Modify">
</form>
<?php
    if (isset($_POST['submit']))
    {
        $u="UPDATE myaduan SET nama_pengadu='$_POST[inputName]', aduan_details'$_POST[inputDec]'
        WHERE ID=$_POST[id]";
        mysql_query($u) or die (mysql_error());

        echo "User has been modified!";
        header ("Location:main.php");
    } 
?>

are you sure that id is a column in the myaduan table?

is it upper cased? ID?

is it rowID?

Also, I would encourage you to sanitize your data before inserting it into your database.

<?php include'e.php';
    if(!isset($_POST['submit'])) //this is confusing
    {
        $id = mysql_real_escape_string($_GET[id]); //since the data you seem to care about is a GET....
        $q="SELECT * FROM myaduan WHERE id=" . $id;
        $result=mysql_query($q);
        $myaduan=mysql_fetch_array($result);
    }
?>

also, you may want to consider migrating from this proceedural, and now outdated, method and instead look into mysqli which is very similar in syntax but has future support for PHP.

http://php.net/manual/en/book.mysqli.php

Member Avatar for Warrens80

What ryantroop said is about all you can do

it's not working and display following errors , please someone help me

Notice: Use of undefined constant id - assumed 'id' in C:\xampp\htdocs\draft3\Edit.php on line 4

Notice: Undefined index: id in C:\xampp\htdocs\draft3\Edit.php on line 4

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\draft3\Edit.php on line 7

erm..

$_GET["id"];

sorry.

hi

i think you have missed '=' in line 21

 $u="UPDATE myaduan SET nama_pengadu='$_POST[inputName]', aduan_details'$_POST[inputDec]' WHERE ID=$_POST[id]";

replace the above code as below

$u="UPDATE myaduan SET nama_pengadu='$_POST[inputName]', aduan_details='$_POST[inputDec]' WHERE ID=$_POST[id]";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.