Page 1 of 1

Notice: Undefined variable: client in C:\xampp\...

PostPosted: 16. August 2012 02:17
by kcjones
Hi! Using XAMPP 1.8.0 and have run into an issue with testing the code. Keep getting an "undefined variable: client in..." on a certain page and i wanted to see if someone can help me debug it. The full notice is "Notice: Undefined variable: client in C:\xampp\htdocs\acp\assessment\template_c\t_assessment_view.php on line 21" AND "Notice: Undefined variable: html in C:\xampp\htdocs\acp\assessment\template_c\t_assessment_view.php on line 98" See code below. I have changed the font color for the
--------------- PHP CODE BELOW --------------------------
Code: Select all
<div style="width:940px;margin:0 auto;">
<div style="float:right"><select name="TakeAssessmentTest"><option value="">Select Assessment Test</option>
<?
foreach($admin->listActiveForms() as $str){
   echo '<option value="'.$str['formId'].'">'.$str['formTitle'].' Ver. '.$str['formVersion'].'</option>';
}
?>
</select>&nbsp;<input type="button" value="New" id="<?=$_GET['uid'];?>" class="clientNewAssess" /></div>[color=#FF0000][b] THIS IS LINE 21[/b][/color]
<h1 style="width:470px"><?=$client['firstName']. ' '.$client['middleInit'].' '.$client['lastName'];?></h1>
</div>
<?
if($form){
   $i = 1;
   $total_risc = 0;
   $data = json_decode($form['assess_answers'], true);
   $compared = (date("Y", strtotime($form['formCreated'])) == date("Y")) ? true : false;
   $html = '<table class="form_table" cellspacing="0">';
   $html .= '<thead><tr><th colspan="3">'.
       $form['formTitle'].' Ver. '.$form['formVersion'];
   if($compared){
      $html .= '<input type="button" id="'.$form['c_a_id'].'" class="editAssessmentC" style="float:right" value="Edit" />';
   }
   $html .= '</th></tr></thead>';
   foreach($data as $key => $str){
      $sql = "SELECT * FROM form_categories WHERE cat_id ='".$key."'";
      $stmt = $admin->db->prepare($sql);
      $stmt->execute();
      $stmt->setFetchMode(PDO::FETCH_ASSOC);
      $o = $stmt->fetch();
      $fac = 0;
      $total[$o['cat_title']][num] = 0;
      
      if($o['question_rating'] != 'None'){
         $sql2 = "SELECT * FROM form_questions WHERE catId='".$key."' AND question_rating = 'Factor'";
         $stmt2 = $admin->db->prepare($sql2);
         $stmt2->execute();
         $stmt2->setFetchMode(PDO::FETCH_ASSOC);
         while($o2 = $stmt2->fetch()){
            $fac = $fac + $o2['question_high_rating'];
            $total[$o['cat_title']][num] = $total[$o['cat_title']][num] + 1;
         }
         $total[$o['cat_title']]['num_questions'] = $stmt->rowCount();
         $sql3 = "SELECT question_high_rating FROM form_questions WHERE catId='".$key."' AND question_rating = 'Social'";
         $stmt3 = $admin->db->prepare($sql3);
         $stmt3->execute();
         $stmt3->setFetchMode(PDO::FETCH_ASSOC);
         $o3 = $stmt3->fetch();
         $soc = $o3['question_high_rating'];
      }
      $total[$o['cat_title']]['factor_score'] = array_sum($str[ratings][factor]);
      $total[$o['cat_title']]['possible_score'] = $fac;
      $total[$o['cat_title']]['social'] = $str[ratings][social];
      $factor = round((((array_sum($str[ratings][factor])/$fac)) * 67), 2);
      $social = round((($str[ratings][social]/$soc) * 33), 2);
      $html .= '<tr><th style="width:700px" colspan="2">'.$o['cat_title'].'</th><th style="width:100px">'.($factor + $social).'</th></tr>';
         foreach($str[answers] as $key1=>$str1){
            $sql4 = "SELECT * FROM form_questions WHERE question_id = :id";
            $stmt4 = $admin->db->prepare($sql4);
            $stmt4->bindParam(':id', $str1[q_id]);
            $stmt4->execute();
            $stmt4->setFetchMode(PDO::FETCH_ASSOC);
            $o4 = $stmt4->fetch();
            $ans = explode("[", $str1['answer']);
            $html .= '<tr>'.
                '<td>'.$i.'.</td>'.
                '<td>'.$o4['question_name'].'<br /><span style="margin:0 5px;">'.$ans[0].'</td>';
            if($o4['question_rating'] == 'None'){
               $style = ' style="background:#CCC"';
            } else {
               $style = ' style="background:#FFF"';
            }
            $html .= '<td'.$style.'>';
            if($o4['question_rating']!='None'){
               $html .= $str1['rating'];
            }
            $html .= '</td></tr>';
            $i++;
          }
          $total_risc++;
   }
   $html .= '</table>';
} else {
   $no = '<strong>No assessments taken.</strong>';
}

if($html){
   echo '<script type="text/javascript">'.
       '$(function(){'.
       '$("#viewAssessmentForm").change(function(){'.
       'window.location = \'assessment.php?page=view&uid='.$_GET['uid'].'&aid=\' + $(this).val();'.
       '});'.
       '});'.
        '</script>';
   echo '<table class="results_table form_table" cellspacing="0">'.
       '<thead><tr><th colspan="6"><div style="float:right"> Go to assessment: <select id="viewAssessmentForm">';
   foreach($taken_a as $tkey=>$tstr){
      $selected = $_GET['aid']==$tstr['c_a_id']? ' selected="selected"' : '';
      echo '<option value="'.$tstr['c_a_id'].'"'.$selected.'>'.$tstr['formTitle'].' - '.date("M d, Y", strtotime($tstr['c_a_date'])).'</option>';
   }
   echo '</select></div>Assessment Date: '.date("M d, Y", strtotime($form['c_a_date'])).'</th></tr>'.
       '<tr><th>Section</th><th># of ?\'s</th><th>Factor Result By</th><th>Initial Rating <u>(20)</u></th>'.
       '<th>Rating</th><th>Social Worker Risk Rating</th></tr></thead><tbody>';
   foreach($total as $key=>$str){
      $factor_rating = round(10 / $str[num], 2) * $str['factor_score'];
      echo '<tr><td>'.$key.'</td><td>'.$str[num].'</td><td>'. round(10 / $str[num], 2) .'</td><td></td><td>' . $factor_rating . '</td><td>'.$str['social'].'</td></tr>';
      $f_r_total[] = $factor_rating;
      $s_r_total[] = $str['social'];
   }
   echo '</tbody><tfoot><td colspan="3" style="border-right:1px solid #fab331">Highest Risk Total on Rating Scale: '.$total_risc * 20 .
       '</td><td style="border-right:1px solid #fab331"></td>'.
       '<td style="border-right:1px solid #fab331">'.array_sum($f_r_total).'</td>'.
       '<td>'.array_sum($s_r_total).'</td></tfoot></table><p>';
   echo $html;
} else {
   echo $no;
};
?>
</p>

------------------ PHP CODE ABOVE -------------------

PLEASE HELP!

Thanks,

Kelvin Jones

Re: Notice: Undefined variable: client in C:\xampp\...

PostPosted: 16. August 2012 02:24
by JJ_Tagy
It's just a notice that it wasn't defined before use. Does the php not execute? You could always not use the '=' sign when displaying the input from your GET variable.

Re: Notice: Undefined variable: client in C:\xampp\...

PostPosted: 16. August 2012 02:34
by kcjones
No, it does not execute at all. Here is a link of what it should look like: http://clients.uwebtech.com/AChildsPlace/assessment.php?page=view&uid=43... my developer is out of pocket for a while and i am left trying to debug... i have put the files on my XAMPP server to do a thorough test before going to a prod server

Re: Notice: Undefined variable: client in C:\xampp\...

PostPosted: 16. August 2012 04:34
by JonB
When you post code - PLEASE use Code Tags.

Thanks -
8)

Re: Notice: Undefined variable: client in C:\xampp\...

PostPosted: 16. August 2012 05:15
by Altrea
Sorry, we can't provide any support for third party scripts.
If you have specific problems you can't solve yourself (error messages, etc) we can try to help you (like JJ_Tagy does with your Notices), but we will not debug your entire script.

Two things that will probably help you:
  • Are you sure, the script is able to run with PHP 5.4? You should use the XAMPP release which fits your live server enviroment the most
  • You are using short_open_tags in your script. These functionality is setted to Off by default in the current XAMPP release

best wishes,
Altrea