". $rows[0]->html);If I replace this line with : echo( $rows[0]->html ); the page gets printed and the following text is displayed instead of the form : setQuery( $query ); $projet = $db->loadObjectList(); echo JHTML::_( 'select.genericlist', $projet, 'projet', 'class="inputbox" align="right" style="width: 207px"', 'value', 'text', $this->projet->projet, 'projet'); ?> On this page, two different forms are displayed, the second form shows but some php code is printed in or above different fields. It looks like PHP is not evaluated because of some tags (echo JHTML::_( 'select.genericlist', $projet, 'projet', 'class="inputbox" align="right" style="width: 207px"', 'value', 'text', $this->projet->projet, 'projet');Here the full code of forms : Rechercher une mission setQuery( $query ); $projet = $db->loadObjectList(); echo JHTML::_( 'select.genericlist', $projet, 'projet', 'class="inputbox" align="right" style="width: 207px"', 'value', 'text', $this->projet->projet, 'projet'); ?> seconf form : Informations sur vous Nom : * "id="nom" tabindex="101" /> Prénom : * Patronyme : Mr Mme Mlle Date de naissance : *  (JJ)   (MM)   (AAAA) Nationalité : * Profession : * ---------------- Employé(e) cadre Employé(e) non cadre Chômeur Chef d'entreprise Libéral Etudiant(e) Retraité(e) Autres Formation/Etudes : Langue(s) Parlée(s) : Sport(s) pratiqué(s) : Email : * Evitez les Emails type Hotmail.com, Hotmail.fr ou Live.fr, ces derniers entrainent des disfonctionnements. Téléphone Fixe : *    Portable :  Adresse : * (suite) Ville : *     Code postal : *   (suite) Pays : *  Traitement médical : Allergie ou autre : Régime particulier : Informations relatives au voyage Intitulé du chantier : * setQuery( $query ); $projet = $db->loadObjectList(); echo JHTML::_( 'select.genericlist', $projet, 'projet_id', 'class="inputbox" style="width: 22em"', 'value', 'text', $_GET[projet], 'projet_id'); ?> Date de séjour souhaité (1): * Aller (1):  (JJ)   (MM)   (AAAA) Retour :   (JJ)   (MM)   (AAAA) Date de séjour souhaité (2): Aller (2):  (JJ)   (MM)   (AAAA) Retour :   (JJ)   (MM)   (AAAA) Date de séjour souhaité (3): Aller (3):  (JJ)   (MM)   (AAAA) Retour :   (JJ)   (MM)   (AAAA) Expérience d'un séjour similaire : N° Adhérent :  (numéro à préciser si vous êtes déjà adhérent à Cybelle Planète) N° chèque cadeau :  (numéro à préciser si vous êtes bénéficiaire d'un chèque cadeau Cybelle Planète) Souhaitez-vous que cybelle planète se charge de réserver votre billet d'avion ? * OUI / NON  (Voir conditions : Lien) Compagnon de voyage Nom :   Prénom : Personne à contacter en cas de besoin Nom : * Prénom : * Lien : * Adresse : * Ville : * Code postal : * Email : Evitez les Emails type Hotmail.com, Hotmail.fr ou Live.fr, ces derniers entrainent des disfonctionnements. Téléphone : * Portable : Informations diverses Laisser un commentaire : Comment avez vous connu Cybelle-Planète ? * Par des amis Par la consultation du site Internet Par la consultation du site Internet suite à une publicité Par la presse: Précisez : Je souhaite recevoir la newsletter électronique de l'association. show_data();What am I missing ?"> localhost migrated forms broken - Forums

Forums

localhost migrated forms broken

Canard 08 Oct, 2014
Hi,
I was contacted by a company using this old version of both JOOMLA and CC (1.5.3/3.1), their website has been running for a long time and was maintained by a developer who is now out of reach. It is now my turn to work on it !
They ask me for different changes, so I downloaded and installed the site on localhost. After some editing in the config file, everything is working properly except Chono Forms which are kind of broken. I get this Error : Fatal error: Using $this when not in object context in C:\wamp\www\cybelle\cybelle2\plugins\content\chronocontact.php(208) : eval()'d code on line 9
which refer to that line (208):
eval("?>". $rows[0]->html);

If I replace this line with :
echo( $rows[0]->html ); 
the page gets printed and the following text is displayed instead of the form :
setQuery( $query ); $projet = $db->loadObjectList(); echo JHTML::_( 'select.genericlist', $projet, 'projet', 'class="inputbox" align="right" style="width: 207px"', 'value', 'text', $this->projet->projet, 'projet'); ?> 

On this page, two different forms are displayed, the second form shows but some php code is printed in or above different fields. It looks like PHP is not evaluated because of some tags (<? and/or ") issue. The forms code is exactly the same as in the production website which is ok. A hint is maybe the second form uses a recaptcha. The PHP code seems to break when doing things like:
echo JHTML::_( 'select.genericlist', $projet, 'projet', 'class="inputbox" align="right" style="width: 207px"', 'value', 'text', $this->projet->projet, 'projet');

Here the full code of forms :
<table  width="200" border="0" >
<tr><td align="center"><h3>Rechercher une mission</h3></td></tr>
    <tr>
      <td align="center">
      <?php $db =& JFactory::getDBO();
              $query = 'SELECT id AS value, nom_court AS text FROM #__projet where published=1 ORDER BY text ASC';
              $db->setQuery( $query );
              $projet = $db->loadObjectList();
              echo JHTML::_( 'select.genericlist', $projet, 'projet', 'class="inputbox" align="right" style="width: 207px"', 'value', 'text', $this->projet->projet, 'projet'); ?> 
      </td>
    </tr>
    <tr>
      <td align="center"><input type="submit" name="gozonedetude" id="gozonedetude" value="Go"></td>
    </tr>
    </table>

seconf form :
<div align="center" id="inscriptionform">
  <table  border="1">
    <tr>
      <td align="center"><strong>Informations sur vous</strong></td>
      </tr>
    <tr>
      <td align="center"><table  border="0">
        <tr>
          <td width="203" valign="bottom">Nom :<font color="red"> *</font></td>
          <td><input type="text" name="nom" value="<?php echo $_GET['nom']; ?>"id="nom" tabindex="101" /></td>
        </tr>
        <tr>
          <td valign="bottom">Prénom :<font color="red"> *</font></td>
          <td><input type="text" name="prenom" id="prenom" tabindex="102" /></td>
          </tr>
        <tr>
          <td valign="bottom">Patronyme :</td>
          <td><select name="patronyme" id="patronyme" tabindex="103">
           <option>Mr</option>
           <option>Mme</option>
           <option>Mlle</option>
            </select></td>
          </tr>
        <tr>
          <td valign="bottom">Date de naissance : <font color="red"> *</font></td>
          <td><input type="text" name="date_naissance_jour" id="date_naissance_jour" tabindex="104" size="1" /> (JJ)  <input type="text" name="date_naissance_mois" id="date_naissance_mois" tabindex="104" size="1" /> (MM)  <input type="text" name="date_naissance_annee" id="date_naissance_annee" tabindex="104" size="3" /> (AAAA) </td>
          </tr>
        <tr>
          <td valign="bottom">Nationalité :<font color="red"> *</font></td>
          <td><input type="text" name="nationalite" id="nationalite" tabindex="105" /></td>
          </tr>
        <tr>
          <td valign="bottom">Profession : <font color="red"> *</font></td>
          <td><select name="profession" id="profession" tabindex="106">
            <option selected>----------------</option>
            <option>Employé(e) cadre</option>
            <option>Employé(e) non cadre</option>
            <option>Chômeur</option>
            <option>Chef d'entreprise</option>
            <option>Libéral</option>
            <option>Etudiant(e)</option>
            <option>Retraité(e)</option>
            <option>Autres</option>
            </select></td>
          </tr>
        <tr>
          <td valign="middle">Formation/Etudes :</td>
          <td><textarea cols="43" rows="2" name="formation" id="formation" tabindex="107"></textarea>
          </td>
          </tr>
        <tr>
          <td valign="bottom">Langue(s) Parlée(s) :  </td>
          <td><input type="text" name="langue" id="langue" tabindex="108" /></td>
          </tr>
        <tr>
          <td valign="bottom">Sport(s) pratiqué(s) :</td>
          <td><input type="text" name="sport" id="sport" tabindex="109" /></td>
          </tr>
        <tr>
          <td valign="bottom">Email : <font color="red"> *</font></td>
          <td><input type="text" name="email" id="email" tabindex="110" /></td>
          </tr>
<tr><td></td><td>Evitez les Emails type Hotmail.com, Hotmail.fr ou Live.fr, ces derniers entrainent des disfonctionnements.</td></tr>
        <tr>
          <td valign="bottom">Téléphone</td>
          <td>Fixe :<font color="red"> *</font> 
            <input name="tel" type="text" id="tel" tabindex="111" size="12" />
              Portable : 
            <input name="portable" type="text" id="portable" tabindex="112" size="13" /></td>
          </tr>
        <tr>
          <td valign="bottom">Adresse : <font color="red"> *</font></td>
          <td><input name="adresse" type="text" id="adresse" size="45" tabindex="113"/></td>
          </tr>
        <tr>
          <td valign="bottom">(suite)</td>
          <td>
Ville :<font color="red"> *</font>  <input type="text" name="ville_ville" id="ville_ville" tabindex="114" size="12"/>   

Code postal :<font color="red"> *</font><input size="4" name="cp" type="text" id="cp" size="12" tabindex="115"/>  
          </td>
          </tr>
        <tr>
          <td valign="bottom">(suite)</td>
          <td>
Pays :<font color="red"> * <input type="text" size="12" name="ville_pays" id="ville_pays" tabindex="114" /></td>
          </tr>
        <tr>
          <td valign="bottom">Traitement médical : </td>
          <td><input name="medical" type="text" id="medical" tabindex="116" size="45" /></td>
          </tr>
        <tr>
          <td valign="bottom">Allergie ou autre : </td>
          <td><input name="allergie" type="text" id="allergie" tabindex="117" size="45" /></td>
          </tr>
        <tr>
          <td valign="bottom">Régime particulier : </td>
          <td><input type="text" name="regime" id="regime" tabindex="118" /></td>
          </tr>
      </table></td>
      </tr>
      <tr>
      <td align="center"><strong>Informations relatives au voyage</strong></td></tr>
    <tr>
      <td align="center"><table border="0">
        <tr>
          <td width="203" valign="bottom">Intitulé du chantier : <font color="red"> *</font></td>
          <td>
            <?php $db =& JFactory::getDBO();

              $query = 'SELECT id AS value, nom_court AS text FROM #__projet where published = 1 order by text ASC';

              $db->setQuery( $query );

              $projet = $db->loadObjectList();

              echo JHTML::_( 'select.genericlist', $projet, 'projet_id', 'class="inputbox" style="width: 22em"', 'value', 'text', $_GET[projet], 'projet_id'); ?>

          </td>
        </tr>
        <tr>
          <td valign="bottom">Date de séjour souhaité (1): <font color="red"> *</font></td>
           <td>Aller (1):  <input type="text" name="aller1j" id="aller1j" tabindex="104" size="1" /> (JJ)  <input type="text" name="aller1m" id="aller1m" tabindex="104" size="1" /> (MM)  <input type="text" name="aller1a" id="aller1a" tabindex="104" size="3" /> (AAAA) </td>   
</tr><tr><td></td>
<td>Retour :  <input type="text" name="retour1j" id="retour1j" tabindex="104" size="1" /> (JJ)  <input type="text" name="retour1m" id="retour1m" tabindex="104" size="1" /> (MM)  <input type="text" name="retour1a" id="retour1a" tabindex="104" size="3" /> (AAAA) </td>
          </tr>
        <tr>
          <td valign="bottom">Date de séjour souhaité (2):</td>
          <td>Aller (2): <input type="text" name="aller2j" id="aller2j" tabindex="104" size="1" /> (JJ)  <input type="text" name="aller2m" id="aller2m" tabindex="104" size="1" /> (MM)  <input type="text" name="aller2a" id="aller2a" tabindex="104" size="3" /> (AAAA) </td>   
</tr><tr><td></td>
<td>Retour :  <input type="text" name="retour2j" id="retour2j" tabindex="104" size="1" /> (JJ)  <input type="text" name="retour2m" id="retour2m" tabindex="104" size="1" /> (MM)  <input type="text" name="retour2a" id="retour2a" tabindex="104" size="3" /> (AAAA) </td>
          </tr>
        <tr>
          <td valign="bottom">Date de séjour souhaité (3):</td>
           <td>Aller (3): <input type="text" name="aller3j" id="aller3j" tabindex="104" size="1" /> (JJ)  <input type="text" name="aller3m" id="aller3m" tabindex="104" size="1" /> (MM)  <input type="text" name="aller3a" id="aller3a" tabindex="104" size="3" /> (AAAA) </td>   
</tr><tr><td></td> 
<td>Retour :  <input type="text" name="retour3j" id="retour3j" tabindex="104" size="1" /> (JJ)  <input type="text" name="retour3m" id="retour3m" tabindex="104" size="1" /> (MM)  <input type="text" name="retour3a" id="retour3a" tabindex="104" size="3" /> (AAAA) </td>
          </tr>
        <tr>
          <td valign="top">Expérience d'un séjour similaire :</td>
          <td><textarea cols="43" rows="5" name="motivation" id="motivation" tabindex="123"></textarea></td>
          </tr>
<tr>
          <td valign="top">N° Adhérent :</td>
          <td><input type="text" name="numeroadh" id="numeroadh" tabindex="115" size="2" /> <i><font size="1">(numéro à préciser si vous êtes déjà adhérent à Cybelle Planète)</font></i>
</td>
          </tr>
<tr>
          <td valign="top">N° chèque cadeau  :</td>
          <td><input type="text" name="numerocadeau" id="numerocadeau" tabindex="115" size="8" /> <i><font size="1">(numéro à préciser si vous êtes bénéficiaire d'un chèque cadeau Cybelle Planète)</font></i>
</td>
          </tr>
<tr>
          <td colspan="2" valign="top">Souhaitez-vous que cybelle planète se charge de réserver votre billet d'avion ?<font color="red"> *</font> OUI<INPUT type=radio name="billetavion" value="OUI"> /
	 NON <INPUT type=radio name="billetavion" CHECKED value="NON"> <i><font size="1">(Voir conditions : <a target="_blank" href="http://www.cybelle-planete.org/cybelle2/index.php?option=com_content&view=article&id=157&itemid=174">Lien</a>)</font></i>
</td>
          </tr>
        
      </table></td>
      </tr>
        <tr><td align="center"><strong>Compagnon de voyage</strong></td></tr>
    <tr>
      <td align="left"><table width="455" border="0">
        <tr>
          <td width="203" align="left">Nom :  </td>
          <td align="left"><input type="text" name="nomcompagnon" id="nomcompagnon" tabindex="125" /></td>
        </tr>
        <tr>
          <td align="left">Prénom :  </td>
          <td align="left"><input type="text" name="prenomcompagnon" id="prenomcompagnon" tabindex="126" /></td>
          </tr>
      </table></td>
      </tr>
      <tr>
        <td align="center"><strong>Personne à contacter en cas de besoin</strong></td></tr>
    <tr>
      <td align="left"><table width="507" border="0">
        <tr>
          <td width="203">Nom : <font color="red"> *</font></td>
          <td><input type="text" name="nomcontact" id="nomcontact" tabindex="127" /></td>
        </tr>
        <tr>
          <td><p>Prénom : <font color="red"> *</font></p></td>
          <td><input type="text" name="prenomcontact" id="prenomcontact" tabindex="128" /></td>
          </tr>
        <tr>
          <td>Lien : <font color="red"> *</font></td>
          <td><input type="text" name="liencontact" id="liencontact" tabindex="129" /></td>
          </tr>
        <tr>
          <td>Adresse : <font color="red"> *</font></td>
          <td><input name="adressecontact" type="text" id="adressecontact" tabindex="130" size="40" /></td>
          </tr>
        <tr>
          <td>Ville : <font color="red"> *</font></td>
          <td><input name="villecontact" type="text" id="villecontact" tabindex="131" size="35" /></td>
          </tr>
        <tr>
          <td>Code postal : <font color="red"> *</font></td>
          <td><input name="cpcontact" type="text" id="cpcontact" tabindex="132" size="12" /></td>
          </tr>
        <tr>
          <td>Email :</td>
          <td><input name="emailcontact" type="text" id="emailcontact" tabindex="133" size="40" /></td>
          </tr>
<tr><td></td><td>Evitez les Emails type Hotmail.com, Hotmail.fr ou Live.fr, ces derniers entrainent des disfonctionnements.</td></tr>
        <tr>
          <td>Téléphone  : <font color="red"> *</font></td>
          <td><input name="telcontact" type="text" id="telcontact" tabindex="134" size="14" /></td>
          </tr>
        <tr>
          <td>Portable :</td>
          <td><input name="portablecontact" type="text" id="portablecontact" tabindex="135" size="14" /></td>
          </tr>
      </table></td>
      </tr>
      <tr>
        <td align="center"><strong>Informations diverses</strong></td></tr>
    <tr>
      <td align="center"><table  border="0">
        <tr>
          <td width="203" valign="top">Laisser un commentaire : </td>
          <td><textarea name="commentaire" id="commentaire" cols="43" rows="5" tabindex="136"></textarea></td>
        </tr>
        <tr>
          <td valign="top">Comment avez vous connu Cybelle-Planète ? <font color="red"> *</font></td>
          <td valign="middle">
               <select name="cybelle" onchange="afficher('pressediv');"  type="text" id="cybelle" tabindex="137">
               <option selected></option>
               <option>Par des amis</option>
               <option>Par la consultation du site Internet</option>
               <option>Par la consultation du site Internet suite à une publicité</option>
               <option>Par la presse: </option>
               </select></td>
          </tr>
			<tr name="pressediv" id="pressediv" style="display:none;">
			<td> Précisez : </td>
			<td><input type="text" name="ipresse" id="ipresse" /></td></tr>
<tr><td colspan="2">
<INPUT TYPE="checkbox" NAME="mailing_eco" VALUE="1" CHECKED> Je souhaite recevoir la newsletter électronique de l'association.
</td></tr>
      </table>

<input type="hidden" id="date_preinscription" name="date_preinscription" value=""/>
</td>
      </tr>
<tr><td colspan="2">
<?php
require_once('stratageo/recaptchalib.php'); // Vérifier que l'URL relative correspond à l'emplacement du fichier (adapter si nécessaire)
$publickey = "6LfECNESAAAAAPLBcb9z3FSAE2xcieNRcMPqeXmH "; // Utiliser la clé que vous avez eu lors de l'inscription sur recaptcha.net
echo recaptcha_get_html($publickey); // Affiche le captcha
?>
</td></tr>
    <tr>
      <td align="center"><input type="submit" name="envoyer" id="envoyer" value="Envoyer" tabindex="139" /></td>
      </tr>
  </table>
</div>
<input type="hidden" name="sujet" id="sujet" value="" /> 
<input type="hidden" name="projet2" id="projet2" value="" /> 

<input type="hidden" name="date_naissance" id="date_naissance" value="" />
<input type="hidden" name="ville" id="ville" value="" />

<input type="hidden" name="depart1" id="depart1" value="" />
<input type="hidden" name="arrive1" id="arrive1" value="" />

<input type="hidden" name="depart2" id="depart2" value="" />
<input type="hidden" name="arrive2" id="arrive2" value="" />

<input type="hidden" name="depart3" id="depart3" value="" />
<input type="hidden" name="arrive3" id="arrive3" value="" />
<script>
show_data();
</script>






What am I missing ?
Max_admin 08 Oct, 2014
Hi Canard,

The form with the error has a "$this" word in the HTML code, please open the form and find the line with this word, and post it here!

Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
Canard 08 Oct, 2014
Right, here's the form's html code :
echo JHTML::_( 'select.genericlist', $projet, 'projet', 'class="inputbox" align="right" style="width: 207px"', 'value', 'text', $this>projet->projet, 'projet'); 
Canard 08 Oct, 2014
sorry, missing hyphen :
  echo JHTML::_( 'select.genericlist', $projet, 'projet', 'class="inputbox" align="right" style="width: 207px"', 'value', 'text', $this->projet->projet, 'projet');
Max_admin 08 Oct, 2014
1 Likes
Ok, so this reference can't be used here:
$this->projet->projet


You need to correct it, you already have a $projet variable, so maybe its just $projet->projet ?
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
Canard 08 Oct, 2014
Thank you for pointing that out, so do you think that I should use another way to build the drop-down list ?
if I understand correctly, the $this->project part of code gets the $_POST['project'] variable in order to set the selected option.
I found this tutorial about building drop-downs in chrono forms, maybe is it the right way to do it ?
GreyHead 08 Oct, 2014
Answer
1 Likes
Hi Canard,

Just adding to Max's comment. The $project object is being created from a database query here
<?php
$db =& JFactory::getDBO();
  $query = 'SELECT id AS value, nom_court AS text FROM #__projet where published=1 ORDER BY text ASC';
  $db->setQuery( $query );
  $projet = $db->loadObjectList();
  echo JHTML::_( 'select.genericlist', $projet, 'projet', 'class="inputbox" align="right" style="width: 207px"', 'value', 'text', $this->projet->projet, 'projet');
?> 

I suspect that:
+ $this->projet->projet should just be $projet as loadObjectList() returns an array of objects.
+ loadObjectList may not be the right method to use here - check what the select.genericlist spec requires - it may be a straight array.
+ the code needs something extra to handle the case when there are no results found.

Bob
Canard 08 Oct, 2014
Thanks for the quick reply !
Your remarks guided me to the right direction, the problem was not the object array method as select.genericlist is ok with that but actually the selected option setting (formerly
$this->projet->projet
)
I had to use $_POST variable instead of $this->project.
Here is the final working code :
 <?php $db =& JFactory::getDBO();
	   if($db){
	  
              $query = 'SELECT id AS value, nom_court AS text FROM #__projet where published = 1 order by text ASC';

              $db->setQuery( $query );

              $projet = $db->loadObjectList();
			  
			  if(count($projet)>0)
			  {
			
			   echo JHTML::_( 'select.genericlist', $projet, 'projet', 'class="inputbox" align="right" style="width: 207px"', 'value', 'text',$_POST[projet], 'projet');
			   }
			  } 
			  ?>

Thank you again, really grateful to find people willing to help !
GreyHead 08 Oct, 2014
Hi Canard,

That's good,

Just FYI, ChronoForms adds all the $_POST (and $GET) variables to the $form->data array so you could equally have used $form->data['project'] there.

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