I already have a database table called "form"; I added a new field in same table.

The problem is in the query select * from "form". While the old fields display, the new field doesn't.

I have no idea why yet nothing displays; the query is correct. The error is:

Undefined variable: Num in C:\xampp\htdocs\velocizzare\modules\mod_client\mod_client.php on line 96
Trying to get property of non-object in C:\xampp\htdocs\velocizzare\modules\mod_client\mod_client.php on line 96

My code is:

    $user = JFactory::getUser();
    $db = JFactory::getDBO(); 
    $db->setQuery ($queri); 
    $users = $db->loadObjectList();
    foreach ( $users as $us){
        $Num->$us->Num;                                      // <-- Line 96


        echo"<br />Nome: $Nome";
        echo"<br />Cognome: $Cognome";
        echo"<br />E-mail: $Email";
        echo"<br />Tel/Cellulare: $TelCellulaire";
        echo"<br />Autre Tel: $AutreTel";
        echo"<br />Data di nascita: $DataDiNascita";
        echo"<br />Ville: $Ville";
        echo"<br />Pays de Naissance: $PaysNaissance";
        echo"<br />Residente in (Citta): $ResidenteInCitta";
        echo"<br />Provincia: $Provincia";
        echo"<br /> Num: $Num";

I cleared the cache, it does not work enter image description here Please what's the solution?

The result: enter image description here

1 Answer 1


Problem is this $Num->$us->Num;. You're not defining it correctly.

So replace it with this:

$Num = $us->Num;

You may also want to improve your code a little. Try the following:

$jinput       = JFactory::getApplication()->input;
$BtnConsulter = $jinput->get('BtnConsulter', '');

if ($BtnConsulter)
    $user    = JFactory::getUser();
    $session = JFactory::getSession();
    $db      = JFactory::getDbo(); 

    $session->set('del', $BtnConsulter);

    $query = $db->getQuery(true);
          ->where($db->qn('NuméroK10') . ' = ' . $db->q($BtnConsulter));
    $db->setQuery ($query); 

    $users = $db->loadObjectList();

    foreach ($users as $us)
        $Cognome          = $us->Cognome;
        $civilite         = $us->civilite;
        $Email            = $us->Email;
        $TelCellulaire    = $us->TelCellulaire;
        $AutreTel         = $us->AutreTel;
        $DataDiNascita    = $us->DataDiNascita;
        $Ville            = $us->Ville;
        $PaysNaissance    = $us->PaysNaissance;
        $ResidenteInCitta = $us->ResidenteInCitta;
        $Provincia        = $us->Provincia;
        $Num              = $us->Num;

        echo "<br>Nome: $Nome";
        echo "<br>Cognome: $Cognome";
        echo "<br>E-mail: $Email";
        echo "<br>Tel/Cellulare: $TelCellulaire";
        echo "<br>Autre Tel: $AutreTel";
        echo "<br>Data di nascita: $DataDiNascita";
        echo "<br>Ville: $Ville";
        echo "<br>Pays de Naissance: $PaysNaissance";
        echo "<br>Residente in (Citta): $ResidenteInCitta";
        echo "<br>Provincia: $Provincia";
        echo "<br>Num: $Num";

When declaring the result set variables inside of the foreach() loop, use spacing/tabs to align the = assignment operator. This will help you to see any inconsistencies in your code. This technique is employed in a few places in the Joomla's php coding standards document:

  • @helabriki please take the time to award Lodder's answer with the green tick so that this page is deemed resolved. He has taken the time to not only correct your typo but offer additional advice. "Accepting" an answer also rewards volunteers who take the time to craft correct and helpful answers.
    – mickmackusa
    Jan 31, 2019 at 11:48
  • The isset($BtnConsulter) check is useless, right? Isn't the empty string 2nd param on get() ensuring that the variable will contain something and be set? I don't see NuméroK10 in the screenshot so I don't know what an appropriate default value should be. Maybe empty() or =='' might be better a check.
    – mickmackusa
    Jan 31, 2019 at 11:55
  • @mickmackusa - yes, isset probably isn't the best check to perform
    – Lodder
    Jan 31, 2019 at 12:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.