dougu5847 2011-02-01 20:58
浏览 53

fwrite没有把 放在我的文件中(对于textareas comin中提供的数据来自帖子)

im trying to make a function that saves my configuration data for an automatic email.

the data is coming from textareas so $_POST and put into this function.

My saving function is not saving the caracteres so no line breaks. so when i send a email the full message in 1 big string with no line breaks...

if i open the file it is saved with spaces instead of it all being on 1 line.

if ($_POST['gdwemail_obj']!="") { $gdwEConfig['gdwemail_obj'] = $_POST['gdwemail_obj']; }
if ($_POST['gdwemail_mes']!="") { $gdwEConfig['gdwemail_mes'] = $_POST['gdwemail_mes']; }
saveEConfig($gdwEConfig);



function saveEConfig($post) {
    $gdw_conffile = 'components'.DS.'com_gdwformulaire'.DS.'included'.DS.'econfig.gdw.php';
    $gdw_confopen = fopen($gdw_conffile,'w+');
    $gdw_cfgput  = '<?php';
    $gdw_cfgput .= ' $gdwEconf = array(); ';

    $gdw_cfgput .= ' $gdwEconf[\'gdwemail\'] = "'.$post['gdwemail'].'"; ';
    $gdw_cfgput .= ' $gdwEconf[\'gdwemail_obj\'] = "'.$post['gdwemail_obj'].'"; ';
    $gdw_cfgput .= ' $gdwEconf[\'gdwemail_mes\'] = "'.$post['gdwemail_mes'].'"; ';

    $gdw_cfgput .= '?>';
    if (!fwrite($gdw_confopen, $gdw_cfgput)) {
        echo "<script> alert('ERROR: Can't save configuration file, please verify CHMOD access on \'administrator/components/com_ai/\' for write access.'); window.history.go(-1); </script>
";
        exit;
    }    
    fclose($gdw_confopen);
}

the output looks like this:

    <?php $gdwEconf = array();  $gdwEconf['gdwemail'] = "j.robidas@geantduweb.ca";  $gdwEconf['gdwemail_obj'] = "Réservation pour le cours {courschoisi} a été reçus";  $gdwEconf['gdwemail_mes'] = "Cher {nomdemandeur},

Votre demande de réservation a été reçus avec succès.

Information pour votre sélection:
{courschoisi}
{dateheurechoisi}

Merci
L'équipe de Belle vie de chien"; ?>
  • 写回答

3条回答 默认 最新

  • duanbei3747 2011-02-01 21:04
    关注

    Because you aren't actually including in your $gdw_cfgput .= ... lines.

    评论

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)