Results 1 to 3 of 3

Thread: PHP Form

  1. #1
    Join Date
    Aug 2005
    Posts
    18

    Unanswered: PHP Form

    Hello Everyone, I have written a php form that should be summited to the mysql database but could not because of this error " Parse error, unexpected T_STRING in line 390---as shown below:
    Line 390 is:
    .................................................. ................................
    //connect to database
    $conn = mysql_connect("localhost", "taiwo", "taiwo") or die(mysql_error());
    mysql_select_db("property",$conn) or die(mysql_error());

    .................................................. ...............................
    The rest of the code is here below, though some of them below will generate some error after correcting the one above.


    //add to property descriptions table
    $add_property = "insert into pvtpropertydesc values ('', '$_POST[PropertyType]', '$_POST[NumOfRooms]', '$_POST[NumOfSingleRooms]', '$_POST[NumOfDoubleRooms]', '$_POST[Availability]', '$_POST[Month]', '$_POST[Year]', '$_POST[Units]', '$_POST[Period]', '$_POST[parking]', '$_POST[heating]', '$_POST[RentalPeriod]', '$_POST[RentalUnit]', '$_POST[roomfloor]', '$_POST[lift]', '$_POST[AvailableFrom]")";
    mysql_query($add_property) or die(mysql_error());

    //get house_id for use with other tables
    $houseid = mysql_insert_id();
    if (($_POST[bathroom]) || ($_POST[kitchen]) || ($_POST[meal]) || ($_POST[otherFacitities])) {
    //something relevant, so add to amenities table
    $add_amenities = "insert into amenities values ('', '$_POST[bathroom]', '$_POST[kitchen]', '$_POST[meal]', '$_POST[otherFacitities]')";
    mysql_query($add_amenities) or die(mysql_error());
    }



    //if ($_POST[RentalPeriod]) {
    //something relevant, so add to notes table
    // $add_RentalPeriod = "insert into pvtpropertydesc values ('', '$_POST[PropertyType]', '$_POST[NumOfRooms]', '$_POST[NumOfSingleRooms]', '$_POST[NumOfDoubleRooms]', '$_POST[parking]', '$_POST[heating]', '$_POST[RentalPeriod]', '$_POST[AvailableFrom]")';
    // mysql_query($add_note) or die(mysql_error());
    // }

    $display_block = "<h1>Property Descriptions Added</h1>
    <P>Your entry has been added. Continue to the next stage
    <a href=\"form4.php\">add another</a>?</p>";
    }
    ?>


    2. I would like to know how to use "save" insetad of submit to save the form that user filled and when he/she click save, it will be saved unto the database and he/she can continue to the next form.
    3. So, how can I link the next form with "save"..
    4. How can I handle mutiple sesion and multiple users with the PHP code....

    And suggestion will be appreciated. Thanks.
    Dav

  2. #2
    Join Date
    Apr 2005
    Location
    Baltimore, MD
    Posts
    297
    1. Without seeing all of your code...the error is most likely coming from a missing quote or semi-colon before line 390.

    2 & 3. I am not sure what you mean by using "save."

    4. The same code should work for mutliple users/sessions.


    Also, as a side note, make sure that your IF statements are evaluating correctly. It is generally a bad idea to evaluate post variables as booleans because they are passed as strings and often don't return what is expected.
    if (($_POST[bathroom]) || ($_POST[kitchen]) || ($_POST[meal]) || ($_POST[otherFacitities])) {\

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Just a minor point the line number indicates where the parser spotted the error, it doesn;t mean that line is where the error is
    Alikely candidate is the preceeding line(s)
    this is especially true if the indocated line is a bracket.

Posting Permissions

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