Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Parse error with php MySQL

Options
  • 21-10-2010 5:52pm
    #1
    Registered Users Posts: 73 ✭✭


    Hi all,

    I am creating a php page on my site to allow users to edit their accounts. I'm receiving the following error:

    Parse error: parse error in C:\wamp\www\MyWebsite\editmyaccount.php on line 130

    Here is the code:

    <tr valign="top">
    <td class="formlabel">Age:</td>
    <td><span id="age">
    <select name="Age">
    <option value="">Please select your age category</option>
    <option value="1" <?php if (!(strcmp("1", <?php echo htmlentities($row_Users, ENT_COMPAT, 'utf-8'); ?>))) {echo "SELECTED";} ?>>0-15</option>
    <option value="2" <?php if (!(strcmp("2", <?php echo htmlentities($row_Users, ENT_COMPAT, 'utf-8'); ?>))) {echo "SELECTED";} ?>>16-19</option>
    <option value="3" <?php if (!(strcmp("3", <?php echo htmlentities($row_Users, ENT_COMPAT, 'utf-8'); ?>))) {echo "SELECTED";} ?>>20-29</option>
    <option value="4" <?php if (!(strcmp("4", <?php echo htmlentities($row_Users, ENT_COMPAT, 'utf-8'); ?>))) {echo "SELECTED";} ?>>30-39</option>
    <option value="5" <?php if (!(strcmp("5", <?php echo htmlentities($row_Users, ENT_COMPAT, 'utf-8'); ?>))) {echo "SELECTED";} ?>>40-49</option>
    <option value="6" <?php if (!(strcmp("6", <?php echo htmlentities($row_Users, ENT_COMPAT, 'utf-8'); ?>))) {echo "SELECTED";} ?>>50+</option>
    </select>
    <span class="selectRequiredMsg">Required</span></span>
    </td>
    </tr>
    <!-- Initialize the Validation Select widget object-->
    <script type="text/javascript">
    <!-- If no JavaScript
    var age = new Spry.Widget.ValidationSelect("age");
    //-->
    </script>


    I'd really appreciate if anybody would point me in the right direction. Thanks very much in advance.


Comments

  • Closed Accounts Posts: 18,163 ✭✭✭✭Liam Byrne


    You've got PHP tags within PHP tags
    <?php if (!(strcmp("1", <?php echo

    Not only that, but the echo at the end is a command, when in actual fact PHP is looking for the next parameter for strcmp.

    Have you done programming before ?

    I would guess
    <option value="1" <?php if (!(strcmp("1",htmlentities($row_Users, ENT_COMPAT, 'utf-8')))) echo "SELECTED"; ?>>0-15</option>

    Would be closer to what you want.

    I would also set a temporary variable to the result of the htmlentities function, and use that for all the comparisons, instead of unnecessarily calling the function multiple times.


  • Registered Users Posts: 73 ✭✭TunaSaladBB


    Thanks a million, that worked perfectly. I haven't done much programming before. Dreamweaver generated most of that and I've been trying to edit it to do what I want it do. Thanks again for your help.


Advertisement