Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0
This is the forum to discuss the Wrox book Beginning PHP5, Apache, and MySQL Web Development by Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz, Michael K. Glass; ISBN: 9780764579660
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 20th, 2005, 10:05 AM
Registered User
 
Join Date: Nov 2005
Location: Limassol, , Cyprus.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to aargyri
Default Problem with code on Chapter 14

Hello guys does any one now why I get the following error when I click on the button to add a mailing list

Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /web/sites/159/direct-cy/www.directcy.com/emaillists/class.SimpleMail.php on line 4

Please reply if you do

 
Old April 26th, 2006, 03:51 AM
Registered User
 
Join Date: Apr 2006
Location: Newcastle upon Tyne, , United Kingdom.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Kev_Akas Send a message via Yahoo to Kev_Akas
Default

I found I had this error when running my code on a non-PHP5 server. The server was running PHP4. I'll be home tonight so I can test it on my computer and make sure it works.

Kev Atkinson
http://www.kevatkinson.co.uk
 
Old June 5th, 2006, 06:05 AM
Registered User
 
Join Date: Dec 2004
Location: Vanloese, , Denmark.
Posts: 9
Thanks: 0
Thanked 1 Time in 1 Post
Default

Does anybody have a solution to this one?
It is in chapter 14: "Mailing Lists"

Finally I'm so far that I've uploaded to my ISP and her comes the problem. I don't get the message, when I work on my own apache-serve/my own computer. The message is:


Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /domains/www.stegemueller.dk/www/mailingliste/class.SimpleMail.php on line 4

My block with line 4 in it is like this:
<?php

class SimpleMail {
  public $to = NULL;
  public $cc = NULL;
  public $bcc = NULL;
  public $from = NULL;
  public $subject = '';
  public $body = '';
  public $htmlbody = '';
  public $send_text = TRUE;
  public $send_html = FALSE;
  private $message = '';
  private $headers = '';



Thanks a lot in before.

Best Regards,
Hanne B. Stegemüller - Denmark
 
Old June 6th, 2006, 03:37 PM
Registered User
 
Join Date: Dec 2004
Location: Vanloese, , Denmark.
Posts: 9
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi,

In case somebody else has troubles with this, code I can inform you, that it works OK if you do it like this. I consulted a much more expirienced friend, who could tell, that the problem is, that the book is for PHP 5 and some ISPs (ie. mine) are still on PHP 4. Well - if newbie you wouldn't have a clou - and all the codes are new anyway - version 5 or version 500

class.SimpleMail like this:

<?php

class SimpleMail {
  var $to = NULL;
  var $cc = NULL;
  var $bcc = NULL;
  var $from = NULL;
  var $subject = '';
  var $body = '';
  var $htmlbody = '';
  var $send_text = TRUE;
  var $send_html = FALSE;
  var $message = '';
  var $headers = '';

  function send($to = NULL,
                       $subject = NULL,
                       $message = NULL,
                       $headers = NULL) {
    if (func_num_args() >= 3) {
      $this->to = $to;
      $this->subject = $subject;
      $this->message = $message;
      if ($headers) {
        $this->headers = $headers;
      }

    } else {

      if ($this->from) {
        $this->headers .= "From: " . $this->from . "\r\n";
      }
      if ($this->cc) {
        $this->headers .= "Cc: " . $this->cc . "\r\n";
      }
      if ($this->bcc) {
        $this->headers .= "Bcc: " . $this->bcc . "\r\n";
      }

      if ($this->send_text and !$this->send_html) {
        $this->message = $this->body;
      } elseif ($this->send_html and !$this->send_text) {
        $this->message = $this->htmlbody;
        $this->headers .= "MIME-Version: 1.0\r\n";
        $this->headers .= "Content-type: text/html; " .
                          "charset=iso-8859-1\r\n";
      } else {
        $_boundary = "==MP_Bound_xyccr948x==";

        $this->headers = "MIME-Version: 1.0\r\n";
        $this->headers .= "Content-type: multipart/alternative; " .
                          "boundary=\"$_boundary\"\r\n";

        $this->message = "This is a Multipart Message in " .
                         "MIME format\n";
        $this->message .= "--$_boundary\n";
        $this->message .= "Content-Type: text/plain; " .
                          "charset=\"iso-8859-1\"\n";
        $this->message .= "Content-Transfer-Encoding: 7bit\n\n";
        $this->message .= $this->body . "\n";
        $this->message .= "--$_boundary\n";
        $this->message .= "Content-type: text/html; " .
                          "charset=\"iso-8859-1\"\n";
        $this->message .= "Content-Transfer-Encoding: 7bit\n\n";
        $this->message .= $this->htmlbody . "\n";
        $this->message .= "--$_boundary--";
      }
    }

    if (!mail($this->to,$this->subject,$this->message,$this->headers)) {
      //throw new Exception('Sending mail failed.');
      return FALSE;
    } else {
      return TRUE;
    }
  }

}

?>

Best Regards,
Hanne B. Stegemüller - Denmark




Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 14 Code page 620, help needed! Safi BOOK: Beginning ASP 3.0 3 December 8th, 2010 12:43 PM
Chapter 14 Code Error? pherank BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 July 4th, 2008 09:05 PM
code chapter 14 & 15 pierrethienpont BOOK: Professional VB 2005 ISBN: 0-7645-7536-8 1 February 24th, 2007 03:26 PM
Chapter 14 Code example in Oracle DB theinscrutable BOOK: Professional Jakarta Struts 0 January 10th, 2005 01:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.