SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    May 2011
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Notice: Undefined index

    I have set up a database driven Web site selling used boats, boat parts, engines, etc..

    I am in the process of designing entry forms for the owner to update boats, boat parts, etc for sale. I made a form that works for boats. The form for boat parts is not working.



    Here is the html form from the EnterBoatPart.php:
    <form action="ProcessBoatPart.php" method="post" name="addBoatPart" onreset="return confirm('Do you want to clear this form?')">
    <table cellpadding="3" bgcolor="#FFFFFF" >


    <tr>
    <td><label>Part</label></td>
    <td><textarea name=="part" id="part" cols="40" rows="2"></textarea></td>
    <td><label>Price</label></td>
    <td><input type="text" name="price" id="price" size="15" /></td>
    </tr>
    <tr>
    <td><label>Part Description</label></td>
    <td><textarea name="description" cols="40" rows="5"></textarea></td>
    <td><label>Picture</label></td>
    <td><textarea name="picture" cols="40" rows="3"></textarea></td>
    </tr>
    <tr>
    <td><label>Item</label></td>
    <td><input type="text" name="item" id="item" size="11" /></td>
    <td>&nbsp;&nbsp;</td>
    <td>&nbsp;&nbsp;</td>
    </tr>

    <tr>
    <td align="right"><input name="save" type="submit" value="Save" /></td>
    <td colspan="2" align="center"><input name="add_another" type="button" value="Save and Add Another Boat" /></td>
    <td align="left"><input name="reset" type="reset" value="Reset" /></td>
    </tr>
    </table>
    </form>

    Here is ProcessBoatPart.php:

    <?php
    $part = $_POST['part'];
    $price = $_POST['price'];
    $item= $_POST['item'];
    $description = $_POST['description'];
    $picture= $_POST['picture'];




    $dbhost = 'localhost';
    $dbuser = 'root';
    $dbpass = 'password';
    $database = 'used_boats';
    $table = 'Boat_Parts';

    if (!mysql_connect($dbhost, $dbuser, $dbpass))
    die("Can't connect to database");

    if (!mysql_select_db($database))
    die("Can't select database");

    $sql = "INSERT INTO Boat_Parts (CategoryID, PartID, Part, PartDescription, Picture, Price, Item) values ('4', '', '$part', '$desciption', '$picture', '$price', '$item' )";
    echo(mysql_error());
    mysql_query($sql) or die(mysql_error());

    echo "A <strong>$part<br />
    $description<br />
    $picture<br />
    $price<br />
    $item has been added to the database.</strong>";?>
    Code PHP:
     

    This is my error message:

    ! ) Notice: Undefined index: part in C:\wamp\www\ProcessBoatPart.php on line 16
    Call Stack
    # Time Memory Function Location
    1 0.0011 378416 {main}( ) ..\ProcessBoatPart.php:0

    ( ! ) Notice: Undefined variable: desciption in C:\wamp\www\ProcessBoatPart.php on line 37
    Call Stack
    # Time Memory Function Location
    1 0.0011 378416 {main}( ) ..\ProcessBoatPart.php:0
    A
    1980s Antique mahogany Chris-Craft galley table. Not many left in the world. Leafs on both sides fold-down. Table has not been restored. Warehouse stored over 20 years. Iron floor mounts. Mahogany solid.

    $1000 OBO
    625 has been added to the database.

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <td><textarea name=="part" id="part" cols="40" rows="2"></textarea></td>
    I spy with my little eye an extra character.

  3. #3
    SitePoint Member
    Join Date
    May 2011
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you so much! I went over this so many times. I missed that. Then I was getting the same error for description. I noticed I spelled description wrong in the process php. I kept looking at the process php instead of the form.

    I am a newb and will now remember to check everything!

    Thanks again.


Bookmarks

Posting Permissions

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