包含文件时,分页

时间:2015-06-18 11:36:24

标签: php mailchimp

我遇到了一个非常奇怪的问题。一切都在我当地的主机上按预期工作。当我上传到实时服务器时,页面正好切断了我包含文件的位置。只是它下面的白色空间。纳达...

打破的行是:

<? require_once('inc/store-address.php'); if($_GET['submit']){ echo storeAddress(); } ?>

包含的文件是:

<?php
/*///////////////////////////////////////////////////////////////////////
Part of the code from the book 
Building Findable Websites: Web Standards, SEO, and Beyond
by Aarron Walter (aarron@buildingfindablewebsites.com)
http://buildingfindablewebsites.com

Distrbuted under Creative Commons license
http://creativecommons.org/licenses/by-sa/3.0/us/
///////////////////////////////////////////////////////////////////////*/


function storeAddress(){

   // Validation
   if(!$_GET['email']){ return "No email address provided"; } 

   if(!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*$/i", $_GET['email'])) {
       return "Email address is invalid"; 
   }

   require_once('MCAPI.class.php');
   // grab an API Key from http://admin.mailchimp.com/account/api/
   $api = new MCAPI('xxxxxxx');

   // grab your List's Unique Id by going to http://admin.mailchimp.com/lists/
   // Click the "settings" link for the list - the Unique Id is at the bottom of that page. 
   $list_id = "xxxxxx";


   if($api->listSubscribe($list_id, $_GET['email']) === true) {
      // It worked!   
      // return 'Success! Thank You!';
      echo '<script> window.location.href = "thank-you.php"; </script>';
   }
   else
   {
      // An error ocurred, return error message 
      return 'Error: ' . $api->errorMessage;
   }

}

// If being called via ajax, autorun the function
if($_GET['ajax']){ echo storeAddress(); }
?>

上面代码中编辑的唯一内容是API密钥和列表ID。

2 个答案:

答案 0 :(得分:0)

因为在你的if条件下缺少胃肠道检查。

 require_once('inc/store-address.php'); 

 if($_GET['submit'] **)** { 
    echo storeAddress(); 
 }

答案 1 :(得分:0)

似乎有错误。它正在我的本地服务器上工作,因为没有错误。

我正在使用filezilla上传我的内容。出于某种原因,上传时似乎是编码问题。

我不知道是否应该删除这个问题或答案,以便稍后帮助其他人解决问题,所以我选择了以后的问题。

我手动上传了我的文件并猜测它是什么,它有效!