0

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");
    } 
?>

Edited by Dani: Moved to PHP forum

4
Contributors
5
Replies
23
Views
3 Years
Discussion Span
Last Post by rpv_sen
0

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

0

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

Edited by erminasrcutp

0

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]";
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.