控制器功能代碼:獲取笨錯誤 - 一個PHP錯誤遇到消息:試圖讓非對象的屬性
$surveydata = $this->getsurveydatabasedonId($SurveyId);
$this->load->view('editsurvey', array('surveydata' => $surveydata));
視圖代碼:
<h1 class="page-header">Edit Survey</h1>
<?php
$att = array('id' => 'editsurvey_form', 'role' => 'ajax-form');
echo form_open('welcome/editsurvey', $att);
?>
<div class="span5 offset1" id="form_div">
<?php echo validation_errors('<div class="alert alert-danger reg_error">', '</div>'); ?>
<div class="form-group control-group warning">
<input name="SurveyId" style="display:none" type="text" class="form-control" data-validation-required-message="Please enter a Survey Id" id="SurveyId" required placeholder="Please enter the Survey Id" value="<?php echo set_value('SurveyId', $surveydata->SurveyId); ?>">
<label for="SurveyTitle">Survey Title</label>
<input name="SurveyTitle" type="text" class="form-control" data-validation-required-message="Please enter a Survey Title" id="SurveyTitle" required placeholder="Please enter the Survey Title" value="<?php echo set_value('SurveyTitle', $surveydata->SurveyTitle); ?>">
<p class="help-block"></p>
</div>
<div class="form-group control-group warning">
<label for="SurveyIntroduction">Survey introduction</label>
<textarea name="SurveyIntro" type="text" class="form-control" id="SurveyIntro" placeholder="Enter the Survey Introduction"><?php echo set_value('SurveyIntro', $surveydata->SurveyIntro); ?></textarea>
</div>
<button type="submit" class="btn btn-large btn-warning">Edit Survey</button>
</div>
</form>
我得到出現以下錯誤:
A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: views/editsurvey.php
Line Number: 11
我正在通過陣列,但它無法正常工作有人可以幫我嗎?
'$ surveydata'是否在控制器中包含密鑰'surveydata'? – Rikesh
是的,它確實已經放置了控制器代碼以及 – vini
您可以檢查'var_dump($ surveydata);'在您的視圖文件的頂部?\ – Rikesh