Notice: Undefined index: id in C:\xampp\htdocs\project1\edit.php on line 4

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • waqar haider
    New Member
    • Dec 2012
    • 1

    Notice: Undefined index: id in C:\xampp\htdocs\project1\edit.php on line 4

    i get the id value right from the database but in the update statement doesn't work....


    Code:
    <?php
    mysql_connect('localhost','root','');
    mysql_select_db('project_1');
    $id =$_GET['id']; 
    $title = $_POST['title'];
    $discr = $_POST['discr'];
    $location = $_POST['location'];
    $date = $_POST['date'];
    echo $id;
    if(isset($id) && isset($title) && isset($discr) && isset($location) && isset($date)){
    echo $id;
    $query = "UPDATE `project_1`.`event_manager` SET `event_manager`.`event title`='$title',`event_manager`.`discription`='$discr',`event_manager`.`location`='$location',`event_manager`.`date/time`='$date' WHERE `event_manager`.`id`=`$id`";
    if(mysql_query($query)){
    echo 'the table s updated';
    }
    }
    ?> <form action='http://bytes.com/edit.php' method='POST'>
    title:<br/><input type="text" name="title"><br/><br/>
    discription:<br/><input type="text" name="discr"><br/><br/>
    location:<br/><input type="text" name="location"><br/><br/>
    date:<br/><input type="text" name="date"><br/><br/> <input type='submit' value='update' name='update'> </form>
    Last edited by zmbd; Dec 8 '12, 08:28 PM. Reason: [Z{Please use the <CODE/> button to format posted code/html/sql}]
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    OK, I get to say it this time :)
    Just telling us that something doesn't work is often not enough. Please tell us what is that you expected to happen, what is that is actually happening, and any errors (including the number) that you have received.

    With that said....
    what is up with all of these single quotes:
    `project_1`.`event_manager` in line 12
    Honestly I don't know PHP; thus, I may be off - however, it looks awfully strange to me
    Last edited by zmbd; Dec 8 '12, 08:33 PM.

    Comment

    • Rabbit
      Recognized Expert MVP
      • Jan 2007
      • 12517

      #3
      Line 4, why is that the only one using GET when the others are using POST?

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        With that said....
        what is up with all of these single quotes:
        `project_1`.`ev ent_manager` in line 12
        Honestly I don't know PHP; thus, I may be off - however, it looks awfully strange to me
        these are not single quotes, these are backticks and they are used to quote a MySQL field/table name (e.g. if the name would otherwise be invalid (containing a space or a registered keyword))

        Comment

        • zmbd
          Recognized Expert Moderator Expert
          • Mar 2012
          • 5501

          #5
          Dormilich: Thank you for the information. As I stated, I don't know PHP :) For the same thing in the languages I do code in I'd be using the square braces "[]" It is interesting that PHP would break with that convention.

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            that’s not a PHP thing, that is MySQL-style SQL. PHP merely passes the string to the DB but does itself nothing with it.

            besides that, I never heard of such a convention. I could as well state that your languages break the convention *gg*
            Last edited by Dormilich; Dec 9 '12, 03:58 PM.

            Comment

            • zmbd
              Recognized Expert Moderator Expert
              • Mar 2012
              • 5501

              #7
              and to that I'd say MicroSoft
              (ROTFL)

              Comment

              Working...