我是php和mysql的新手,我正在使用像CMS这样的脚本,我的问题是我可以写新文章,但是当在chrome或opera上编辑它时,所有文章内容都不显示用于编辑和删除它不是firefox的情况,在编辑php脚本下面,
<?php echo link_tag('assets/themes/' . $this->selected_theme . '/'.UIKIT_VERSION.'/css/' . $this->session->userdata('selected-theme')); ?>
<script src="<?php echo base_url() ?>assets/themes/<?php echo $this->selected_theme . '/ckeditor/ckeditor.js'; ?>"></script>
<h4><i class="uk-icon-edit"></i> edit step </h4>
<hr class="uk-article-divider">
<?php $this->load->view('user/template/default/flash_data') ?>
<?php
$attributes = array(
'method' => 'post',
'class' => 'uk-form'
);
echo form_open_multipart('articles/edit/' . $step->step_id, $attributes) ?>
<div class="uk-form-controls">
<label class="uk-form-label">
<?php if ($step->step_photo_url) { ?>
<img src="<?php echo $step->step_photo_url ?>" class="uk-thumbnail-small"/><br/>
<?php } else { ?>
<i class="uk-icon-image uk-icon-large"></i>
<?php } ?>
</label><br/>
<input type="file" name="step_photo_url"/>
<br/>
<label class="uk-form-label uk-text-muted uk-text-bold">Or Enter a URL</label>
<input class="uk-width-90 uk-form-large" type="text" placeholder="Image Url" name="step_photo_url"
value="<?php echo set_value('step_photo_url', $step->step_photo_url, true) ?>"/>
<?php echo form_error('step_photo_url') ?>
</div>
<div class="uk-form-controls uk-margin-top">
<div class="uk-form-controls uk-margin-bottom">
<input value="<?php echo $step->step_title ?>" name="step_title" class="uk-width-90 uk-form-large"
type="text" placeholder="step title">
<?php echo form_error('step_title'); ?>
</div>
<div class="uk-margin-bottom uk-form-controls">
<textarea name="step_description" rows="4" class="uk-width-90 uk-form-large ckeditor"
placeholder="Enter Description"><?php echo set_value('step_description', $step->step_description,
true) ?></textarea>
<?php echo form_error('step_description'); ?>
</div>
<a href="<?php echo site_url('articles/delete/' . $step->step_id) ?>"
class="uk-button uk-button-danger uk-float-left">Delete</a>
<button class="uk-button uk-button-success uk-float-right">Save</button>
</div>
</form>
答案 0 :(得分:0)
这是一个难以猜测的问题,虽然这听起来像我第一次开始使用PHP和数据库时犯的错误。这是使用htmlspecialchars($value,ENT_QUOTES)
在值字段中转换输出。如果你有这个值:
$content = '"What are you talking about?" she asked, "that is ridiculous!"';
然后你回到输入字段进行编辑:
<input name="test" value="<?php echo $content ?>" />
html输出为:
<input name="test" value=""What are you talking about?" she asked, "that is ridiculous!"" />
有两组引号,然后大多数浏览器会将该字段显示为空白。然后,当您单击更新时,它会清除您之前拥有的内容。要解决这个问题,你应该使用:
<input name="test" value="<?php echo htmspecialchars($content,ENT_QUOTES) ?>" />
然后在字段中为您提供此输出:
"What are you talking about?" she asked, "that is ridiculous!"
但是html看起来像这样:
<input name="test" value=""What are you talking about?" she asked, "that is rediculous!"" />
根据您的描述并根据个人经验,这只是在黑暗中刺伤。您将必须显示您的html或某些php值以获得更清晰的图片。