Unhelpful code tidying?

olaeblue 08 Oct, 2011
I am trying to add some php to my form html code so that if you have already registered you don't have a drop down option.

The code I want is
<?php
    $db =& JFactory::getDBO();
    $query = "
      SELECT `cf_id`
        FROM `#__chronoforms_data_meets`
        WHERE `cf_user_id` = ".$user->id." and `meet_name` = 'Lakes Christmas Meet Dec 2011' ;
    ";
    $db->setQuery($query);
    $d = $db->loadResult();
    if ( $d ) {
      echo "<option value=\"Self\" selected>Self</option>";
    }
    ?>


But whenever I save the form the echo line goes to
echo "<option value="Self" selected>Self</option>";

Which, usurprisingly throws up a parse error😟
What is 'cleaning up' the \ and how do I stop it please?? :?
GreyHead 09 Oct, 2011
Hi olaeblue,

Please try
echo '<option value="Self" selected>Self</option>';


Bob
olaeblue 09 Oct, 2011
Thanks that worked but why won't \" work? Is it not valid syntax?
GreyHead 10 Oct, 2011
Hi olaeblue,

It's valid PHP I think; but because this code is being saved in the database, recovered then evaluated some valid PHP doesn't survive the multiple processing.

Bob
This topic is locked and no more replies can be posted.