Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Parse error with php MySQL

  • 21-10-2010 05:52PM
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 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