Results 1 to 3 of 3

Thread: Notice: Undefined index: id, can not inline edit

  1. #1
    Join Date
    Jan 2016

    Notice: Undefined index: id, can not inline edit


    I have a form, the meaning is that you can inline edit and then click on the button update.
    this does not work.
    But I get the notice Undefined index: id.
    The get variable id is not working, or not declared or something else.

    my question is: how can I fix this so that you can inline edit?

    thanks in advance.

    the code is:
    ini_set('display_errors', 1);
    require_once ("includes/connect.php");
    $query = "SELECT * FROM member ";
    $result = mysqli_query($con, $query)    or    die(mysqli_error());
     $id = $_GET['foto_id'];
    echo "<form action='edit.php?id=" . $id . " method='POST'> ";
    echo "<table border='1'>";
    echo "<tr>";
    while ($record = mysqli_fetch_assoc($result)) {
         $id = $record['foto_id'];
        $lid1 = $record['redactie1'];
        $lid2 = $record['redactie2'];
        $lid3 = $record['redactie3'];
        $lid4 = $record['redactie4'];
          echo "<th></th>";
          echo "<th></th>";
          echo "<th></th>";
        echo "</tr>"; 
        echo "<tr>";
        <td><textarea name="lid1" ><?php echo $lid1; ?></textarea></td>
        <td><textarea name="lid2" ><?php echo $lid2; ?></textarea></td>
        <td><textarea name="lid3" ><?php echo $lid3; ?></textarea></td>
        <td><textarea name="lid4" ><?php echo $lid4; ?></textarea></td>
        <td><input type="submit" name="update" value="update" /></td>
        echo "</tr>";
    echo "</table>";
    echo "</form>";

  2. #2
    Join Date
    Mar 2012
    I suspect that the problem may be here:
    $id = $_GET['foto_id'];
    You usually should test for a GET variable before assigning it, and set a default if it is not set (or handle it some other way). E.g.:
    if( isset($_GET['foto_id'])) {
    $id = $_GET['foto_id'];
    } else {
    Also, I note that $id is being set later in the code. So is 'foto_id' a GET variable at all?
    Last edited by jedaisoul; 04-25-2017 at 05:14 PM.

  3. #3
    Join Date
    Jul 2013
    Voorheesville NY USA
    Did you write this code?

    Do you know what you want to do and how well this form/script aligns itself with what your goal is?

    IMHO this is a mess.

    You wonder why the get id is not working yet you don't do any check to see if it exists before attempting to use it. Perhaps the user did not include it in the url he used to access this script. Don't you think you should check.

    One principle that I use is to always check the inputs before DOING anything! Why waste your time and resources until you know what the user/script has given you?

    Check for the GET['ID'] and then decide what you need to do with the script. That will solve your first question. As for the rest - if you wrote it then you need to go back to page one in your learning experience. Sorry.

    From the looks of the fieldnames you are using your database doesn't look like it is normalized. More problems.

    And - you do a query for all the records in your table yet you write an action attribute to handle just a single id. Hmmm... Seems odd.
    PS - If you're posting here you should be using:

    ini_set('display_errors', '1');

    at the top of ALL php code while you develop it!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center