SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist
    Join Date
    Oct 2005
    Posts
    405
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Parse Error Confusion about Braces {}?

    I keep getting a parse error

    Code:
    Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/sites/normanbar.co.uk/public_html/admin/send.php on line 38

    I'm unsure why as i can't locate it in the code. Any tips?

    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <link href="../css/admin.css" rel="stylesheet" type="text/css" />
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <title>Norman Bar Admin</title>
    </head>

    <body>
    <div id="main">

    <h1>Newsletter Sent</h1>

    <p><a href="index.php">Back</a></p>

    <p>Your newsletter has been sent to 
    <?php

    if ($_POST['test'] == 'on') {
    ?>
    yourself only.
    <?php
    }else {
    ?>
    all subscribed users.
    <?php
    }

    ?>

    <BR>Thank You</p>


    <?php

    class Envy_Mailer {

        public 
    $Subject 'No subject specified';
        public 
    $XMailer 'Envy Point Mailer';
        public 
    $RecipientsList = array();
        
        public 
    $SenderName 'Leeds';
        public 
    $SenderEmail gh@h.com';
        
        public $Message = '
    No message content specified';

        public function __construct (){
        
        }
        
        /**
         * Add recipient to the mailing list 
         *
         * @param $Name  string
         * @param $Email string
         * @access public
         * @return
         */
        public function AddRecipient ($Name = '
    Customer', $Email) {
            $this->RecipientsList[] = array ($Name, $Email);
        }
        
        /**
         * Send e-mail to all recipients 
         *
         * @access public
         * @return 
         */
        public function Send (){
            
            $Headers  =    '
    From'.$this->SenderName.' <'.$this->SenderEmail.'>'. "\r\n";
            $Headers .= '
    Content-typetext/htmlcharset=iso-8859-1\r\n';        
            $headers .= "MIME-Version: 1.0\r\n";
            $Headers .= '
    X-Mailer'.$this->XMailer.'\r\n'; 
            
            foreach ($this->RecipientsList as $Recipient) {
                   mail($Recipient[1], $this->Subject, stripslashes($this->Message), $Headers);
            }
            
        }


    }



        mysql_connect('
    localhost', '88888', '54545');
        mysql_select_db('
    5454545');
        
        $query_news = "select * from register where newsletter = '
    1' order by id DESC";
        $result_news = mysql_query($query_news) or die(mysql_error());
        $file_news = mysql_fetch_array($result_news);
        $total_rows_news = mysql_num_rows($result_news);    
        
        if (!$result_news)    
        {
            print '
    There was a database error when executing';
            print mysql_error();
            exit;
        }    





    $Mail = new Envy_Mailer ();

    $Mail->SenderName = $_POST['
    author'];
    $Mail->Subject = $_POST['
    title'];
    $Mail->Message = $_POST['
    message'];

    if ($_POST['
    test'] == 'on') {
                $Mail->AddRecipient ($Mail->SenderName, $Mail->SenderEmail);
    } else{

            do { 

                $Mail->AddRecipient ($file_news['
    name'], $file_news['email']);

            } while ($file_news = mysql_fetch_array($result_news));
    }

    $Mail->Send();

    ?>

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    replace:
    PHP Code:
        public $SenderEmail gh@h.com'; 
    with
    PHP Code:
        public $SenderEmail 'gh@h.com'
    Also, if you're using PHP4 the public, private and protected keywords are only available in PHP5. use var instead.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  3. #3
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    >Any tips?

    Use an editor with line numbering.

    debuggering-php.html
    debugging PHP

    Not sure if that's what you meant ...

  4. #4
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    cups - you got a typo on the first link - I think. lol
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  5. #5
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    No, that certainly sums up my feelings of exasperation when I was at the same stage as the OP - looking for a missed }
    Syntax highlighting, code-folding, auto-complete and bracket-matching certainly changed my quality of life. Mmmm... vim.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •