简体   繁体   中英

how to handle this error in cakephp 1.3

i use pregmatch to extract image name from article text ...so when admin dont add image in the article he see this error

Notice (8): Uninitialized string offset: 0 [CORE\cake\libs\view\helpers\html.php, line 608]

anyway to stop show this error if the admin don't added image

<?php
  echo $html->link( $html->image($imagename,array('height'=>'250px', 'width'=>'280px')),array('action' => 'view', $article['Article']['id']),array('escape' => false));
   ?>

If I understand correctly, you're parsing the article text to get the image link and the display it somewhere in your view.

Check before echo

<?php
if(isset($imagename) && $imagename != ""){
   echo $html->link( $html->image($imagename,array('height'=>'250px','width'=>'280px')),array('action' => 'view',$article['Article']['id']),array('escape' => false));
}
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM