Hi everybody,

i have error in
Notice: Undefined variable: profile_records in C:\wamp\www\user\apps\frontend\modules\main\templates\profileSuccess.php on line 21

plz help me.

index.php
    <div id="frm_edit" class="float-right">

         I'm <?php echo $profile_records['sex']  ?><br />

        <?php if ($profile_records['birthdate'] ): ?> I was born on <?php echo date("F j, Y", strtotime($profile_records['birthdate'])) ?><br /><?php endif ?>
        <?php if ($profile_records['relationshipstatus'] ):?>I'm <?php echo $profile_records[relationshipstatus] ?><br /><?php endif ?>
        <?php if ($profile_records['Occupation'] ): ?>I'm working as a <?php echo $profile_records['occupation'] ?><br /><?php endif ?>
        <?php if ($profile_records['zoneid'] || $personal['countryid']): ?>I'm now residing in <?php if ($profile_records['zoneId']) echo $profile_records['Zone']  ?><?php echo $profile_records['country'] ?><br /><?php endif ?>
        <br />
         <?php if ($profile_records['aboutme']): ?><i>"<?php echo nl2br($profile_records['aboutme']) ?>"</i><br /><br /><?php endif ?>
        <?php if($profile_records['whatido']): ?><i>"<?php echo nl2br($profile_records['whatido']) ?>"</i><?php endif ?>
        <?php if($profile_records['Whatigo']): ?><i>"<?php echo nl2br($profile_records['Whatigo']) ?>"</i><?php endif ?>

    </div>



    action.class.php
    public function executeEdit(sfWebRequest $request)
     {
    $this->_getCurrentUserDetails();
    $this->frm_edit = new PersonalForm();
    $mdl_personal = new Personal();

    if($request->isMethod('post'))
    {
        $profile_record = $request->getParameter('personal');

        if(is_array($profile_record))
            $profile_record['user_id'] = $this->user_id;
        $mdl_personal->insertRecord($profile_record);

    }
     $this->countries = Doctrine::getTable("Country")->findAll();
    //var_dump($mdl_personal);

  }

Thanks .

Dani AI

Generated

The PHP notice means the template is trying to use a variable that the action never provided. In Symfony 1.x an action property set as $this->foo becomes $foo inside the template. If the action keeps the value in a local variable or uses a different name, the view will see nothing. As pointed out, a singular/plural name mismatch is a common cause.

Fixes to apply in the action (before the template renders):

  • Make sure the action sets the variable the template expects (for example, assign a record or an empty array to the same name the template uses). A typical pattern is to fetch the row for the current user and assign it to the action property so it is available in the template.
  • After handling POSTs, either redirect (PRG pattern) or re-fetch and assign the saved data before rendering. That prevents rendering the template with missing data after an insert.

Template hygiene and robustness:

  • Always quote array keys (for example, ['relationshipstatus']) and keep key naming consistent (case and spelling). Unquoted identifiers are interpreted as constants and trigger notices.
  • Guard accesses with isset() or !empty() checks before echoing values so missing keys do not produce notices.
  • Normalize data in the action (map DB columns to predictable keys) so the template logic stays simple and predictable.

Debug tips:

  • In the action, dump the variable you plan to pass (or log it) to confirm it’s populated and has the expected structure.
  • Enable Symfony dev mode for full tracebacks.
  • Fixing the source of the undefined variable is better than hiding the notice; it prevents subtle runtime bugs and keeps templates stable.

This addresses the undefined-variable symptom and the name/case mismatches hinted at by in the thread.

Where are you getting the $profile_records array information from for the code at the top of the page? I only see it in your code from line 19. Also the code from line 19 has the variable $profile_record and not $profile_records.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.