0

With reference to the CodeIgniter Blank Page question I asked previously.

Some new information has come to light that might shed some light on the problem.

My newly built server (CI 2.1.3 - latest release) where this was working correctly and not giving the WSOD is on a sub-domain of my development server. The WSOD issue is STILL occurring on the "live" site which is not in a sub-domain.

Obviously the "live" site is in public_html and the development version is in the "codeigniter" subdomain. Everything else is identical on both servers. Same PHP 5.3 setup. Same .htaccess file. Same CI 2.1.3 setup, obviously with config changed to point to the sub-domain in "development" and the domain in "live".

The issues are the same. On ENTER PRESS or external link ACTIVATION (such as from an email) I get WSOD in "live" but this works correctly in "development". Every controller that is activated without a button click in "live" gives me WSOD, while ALL the pages work correctly in "development".

As a check, I built a completely fresh CI root install (no sub-domain) and the problem mirrors exactly what is going on in "live".

The processes that are exhibiting the WSOD behaviour do not have views attached but simply print out a message on success.

Here is the code:

.htaccess - in the sub-domain folder of "development" and public_html of "live":

Options -Indexes
Options +FollowSymLinks

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L] 

ErrorDocument 404 /index.php

One of the controllers giving the WSOD in "live" when pasting into browser after logging in, but is working in "development" is inviteusers.php simply takes a Company ID and User ID and sends the user a link with login details for the new account. Some extraneous code in the "message" body has been removed to shorten it:

<?php if ( ! defined('BASEPATH')) exit('No Direct Script Access Allowed');
/**
 * Invite Users Controller
 *
 * ----------------------------------------------------------------------------
 */

class InviteUsers extends MY_Controller
{

    function __construct()
    {
        parent::__construct();
        $this->load->model('UserDetails_model');
        $this->load->helper('date');
    }

    public function index()
    {
        if (!$this->session->userdata('clientid') && !$this->session->userdata('userid')) {
            redirect('login');
        }

        // Add Client ID for All Uninvited Users for a Client
        $lookupid['clientid']   = "CID";

        // Add User ID to Add ONE Uninvited user for a Client
        // Change UserDetails_model to take UID if this option is used
        $lookupid['userid']     = "UID";

        $invites = $this->UserDetails_model->getInvites($lookupid);

        foreach ($invites as $invite) {

            if ($invite['new'] == "Y") {

                $message   = "Hi ".$invite['username']." ".$invite['usersurname'].", \n \n";    
                $this->load->helper('email');

                $this->email->set_newline("\r\n");
                $this->email->from('email@address.com', 'System Messenger');
                $this->email->to($invite['useremail']);
                $this->email->bcc('admin@address.com');
                $this->email->subject('Temporary Login Details');
                $this->email->message($message);

                $sent = $this->email->send();

                if ($sent) {
                    echo "SUCCESS!!!   ";
                    echo "NAME:     ".$invite['username']." ".$invite['usersurname']."   ";
                    echo "E-MAIL:   ".$invite['useremail']."   ";
                    echo "PASSWORD: ".$invite['temppass']."   ";
                    echo "NEW:      ".$invite['new']."";
                }

            } else {

                $message   = "Hi ".$invite['username']." ".$invite['usersurname'].", \n \n";

                $this->load->helper('email');

                $this->email->set_newline("\r\n");
                $this->email->from('email@address.com', 'System Messenger');
                $this->email->to($invite['useremail']);
                $this->email->bcc('admin@address.com');
                $this->email->subject('Temporary Login Details');
                $this->email->message($message);

                $sent = $this->email->send();

                if ($sent) {
                    echo "SUCCESS!!!   ";
                    echo "NAME:     ".$invite['username']." ".$invite['usersurname']."   ";
                    echo "E-MAIL:   ".$invite['useremail']."   ";
                    echo "PASSWORD: ".$invite['temppass']."   ";
                    echo "NEW:      ".$invite['new']."   ";
                }

            }

        }

    }

}
/*
 * End of file inviteusers.php
 * Location: ./application/controllers/inviteusers.php
 */

As I said before - THIS PROCESS IS WORKING IN DEVELOPMENT but gives WSOD in LIVE.

MY_Controller simply performs the session lookups and checks some variables. It is simple and solid and has been working without mods since forever.

I think there may be a BIG CLUE in the fact that it works correctly in a recently set up sub-domain with the SAME .htaccess file and config changed to reflect the URL. All other environment variables are EXACTLY IDENTICAL. Same server, same hosting company, same Apache version running the same modules, same PHP version with the same modules, timeouts, memory etc. set.

The controllers giving the WSOD provide me with quick and easy access to certain admin functions so they must work... And they do... In a "development" sub-domain on an identical server to "live" which runs in public_html.

Community
  • 1
  • 1
Swapo
  • 23
  • 1
  • 1
  • 6
  • turn on error reporting in your index.php `ini_set('display_errors', 1);` – meewog Mar 29 '13 at 12:17
  • Why do you have mod_rewrite rules for the system and application directories? The last block of rules right before the ErrorDocument 404 directive is usually sufficient to activate the front controller. – T.P. Mar 29 '13 at 16:55
  • Thanks! Error reporting is turned ON for EVERYTHING!!! – Swapo Mar 31 '13 at 15:02
  • @ jtp: Dunno... Was in the example .htaccess I copied. It seems to work fine the way it is although after some reading I think I might take the first two rules out!!! As I said - n00b, self taught PHP and CI - I know enough to be dangerous... LOL. – Swapo Mar 31 '13 at 15:03

1 Answers1

0

If a certain conditional scenario is met, you aren't outputting anything!

You are only echoing information if the $sent variable equates to true, AKA your email has sent successfully. If it doesn't, you aren't showing anything! Since there is no actual PHP errors, enabling those won't solve anything (although 99% of the time, that is the problem behind blank pages).

Throw an else statement on there with the email's debugger, and you should get some sort of indication about what's going on.

if ($sent) {
    echo "SUCCESS!!!   ";
    echo "NAME:     ".$invite['username']." ".$invite['usersurname']."   ";
    echo "E-MAIL:   ".$invite['useremail']."   ";
    echo "PASSWORD: ".$invite['temppass']."   ";
    echo "NEW:      ".$invite['new']."";
}
else
{
    echo $this->email->print_debugger();
}

Also, for what it's worth, your .htaccess doesn't need rules for the system and application folders. You also don't need slashes on the front of your RewriteRule URLs (RewriteBase handles that for you).

Options -Indexes
Options +FollowSymLinks

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L] 

ErrorDocument 404 index.php
Aken Roberts
  • 13,012
  • 3
  • 34
  • 40
  • Thanks for the Heads Up... This popped up the fact that my email settings were for development but trying to use a production email address... As Homer says: "DOH!!!" I marked this as the answer as it led directly to the answer after DAYS of checking code for whitespace, commas, semi-colons, quotation marks etc. and getting nowhere. Cryode - if you're ever in South Africa email me and I'll buy you a frosty!!! – Swapo Mar 31 '13 at 15:06
  • I am also going to go through my code and add some sanity checks to stop stuff like this from driving me completely mad... As an ex COBOL hacker - I LUV the re-usability of the MVC OO code paradigm although I tend to revert to type at times and go completely procedural instead of creating the objects... We live and learn!!! Once more - BIG THANK YOU!!! – Swapo Mar 31 '13 at 15:09
  • Went and looked - all the failing pages were because of the incorrect email details! – Swapo Mar 31 '13 at 15:10
  • Glad you were able to solve your problems. I'd love to go to South Africa some day! – Aken Roberts Mar 31 '13 at 17:47