0

I'm experiencing a very odd problem. Everything works as expected on my local host. When I upload to a live server, the page just cuts off right where I'm including a file. Just white space beneath it. Nada...

The line that breaks is:

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

And the file being included is:

<?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(); }
?>

The only thing edited in the above code is the API key and List ID.

jddev2381
  • 55
  • 7

2 Answers2

0

its because is missing parentesis on your if condition.

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

 if($_GET['submit'] **)** { 
    echo storeAddress(); 
 }
napolux
  • 15,574
  • 9
  • 51
  • 70
Tarciso Junior
  • 549
  • 9
  • 16
  • I assumed that was just a typo, as they claim it worked on another system. But you could be right. . – RiggsFolly Jun 18 '15 at 12:19
  • 1
    Typo. Sorry. I fixed it. – jddev2381 Jun 18 '15 at 12:22
  • So you might take a look and compare both php.ini files. I had som problems that was in fact wrong configurations. You should also take a look here http://stackoverflow.com/questions/2184513/php-change-the-maximum-upload-file-size , hope it may help you – Tarciso Junior Jun 18 '15 at 12:30
  • Thanks. I'll look into that next for sure. The thing is, I did a project just a few weeks ago using this exact method (same script in fact) and it worked fine on my live server. (Same server) – jddev2381 Jun 18 '15 at 12:34
0

It seems there was an error. It was working on my local server because there wasn't an error.

I was using filezilla do upload my content. For some reason it appears to be an encoding issue when uploading.

I don't know if I should delete this question or answer to help someone else with the problem later on so I chose the later.

I manually uploaded my file and guess what, it works!

jddev2381
  • 55
  • 7
  • Since you did decide to keep your question here on SO, please accept your own answer. That way, your question will be removed from the "Unanswered" list. – kittykittybangbang Jun 25 '15 at 17:04