CodeIgniter Forums

Full Version: CI - Nettuts+ Day 4 - Error, but code looks the same
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]ktufore[/eluser]
Hi, I've tried to look for other occurrences of this same issue. I'm following along on the great tuts by Jeffrey Way and I've come across an obstacle.

This is the error that I receive:

Code:
( ! ) Parse error: syntax error, unexpected T_IF in C:\wamp\www\ci\application\controllers\emailnewsletter.php on line 31
Call Stack
#    Time    Memory    Function    Location
1    0.0011    695808    {main}( )    ..\index.php:0
2    0.0033    777680    require_once( 'C:\wamp\www\ci\system\core\CodeIgniter.php' )    ..\index.php:198

This is the code that I have:

Code:
<?php

/**
* SENDS EMAIL WITH GMAIL
*/
class Emailnewsletter extends CI_Controller {

    function __construct() {
        parent::__construct();
    }
    
    function index() {
        $this->load->view('newsletter');
    }
    
    function send() {
        
        $this->load->library('email');        
        $this->email->set_newline("\r\n");
        
        $this->email->from('[email protected]', 'Kris Small');
        $this->email->to('[email protected]');
        $this->email->subject('This is an email test');
        $this->email->message('It is working!!  Here is your file.');
        
        $path = $this->config->item('server_root');
        $file = $path . 'c://wamp/www/ci/attachments/yourinfo.txt'
        
        //$this->email->attach($file);
        
        if($this->email->send()) {
            echo 'Your email was sent, maaaaaan';
        }
        
        else {
            show_error($this->email->print_debugger());
        }
    }
}

A couple differences are the name of the file and I actually was receiving an error when sending the emails through googlemail (but it works when using gmail in its place). The original error message referred to the commented out code (//$this->email->attach($file)Wink but then I saw that Jeffrey Way commented that out but then the errors just move down the lines of code. Is there any errata or am I missing something simple?

Thanks!

El Forum

[eluser]troy_mccormick[/eluser]
Just a missing semi-colon:

Code:
<?php
        $file = $path . 'c://wamp/www/ci/attachments/yourinfo.txt'; // <-- missing here

El Forum

[eluser]ktufore[/eluser]
Thank you very much. You think you check for all the simple things....