Jump to content


Photo

MAiLING LIST HELL


  • Please log in to reply
12 replies to this topic

#1 Abalone

Abalone
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 30 August 2006 - 05:34 PM

Im getting an error I dont understand

Parse error: parse error, unexpected T_NEW in /home/content/f/t/p/ftpcarrie/html/mail/class.SimpleMail.php on line 78

here is the code:

}

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

#2 HeyRay2

HeyRay2
  • Members
  • PipPipPip
  • Advanced Member
  • 223 posts

Posted 30 August 2006 - 05:53 PM

What version of PHP are you running?

I believe that only PHP5 has exception handling.

#3 Abalone

Abalone
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 30 August 2006 - 05:59 PM

I called my hosting company and they assure me that they have PHP 5, but if I dont have it what could I do to make this statement work with 4?

Thank you so much for your reply, I appreciate it alot.

#4 HeyRay2

HeyRay2
  • Members
  • PipPipPip
  • Advanced Member
  • 223 posts

Posted 30 August 2006 - 06:19 PM

Before we go changing code, let get 100% sure on your PHP version.

Create a php script with the following code:

<?php

// Show information for your PHP installation
phpinfo();

?>

...upload it to the root of your website as info.php (or something similar), and then run it from your browser.

Let us know what PHP version it reports, and any settings that deal with error and exception handling.



#5 Abalone

Abalone
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 30 August 2006 - 07:26 PM

Ok i talked to the hosting guys again, and they say I have to add 5 at the end of my extentions.  So I did that and now im getting a completley new error

Warning: Cannot modify header information - headers already sent by (output started at /home/content/f/t/p/ftpcarrie/html/mail/class.SimpleMail.php5:66) in /home/content/f/t/p/ftpcarrie/html/mail/admin_transact.php5 on line 80

So i check around, I promise I try to figure this out before I ask hehe,  and It says that this error generally means whitespace at the end and beginning of the <?php etc.  I looked and there is no white space so...

I dunno
Thank you so much


here is the code:
Simple mail

<?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 = '';

public 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 this 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;
}
}
}
?>

And

#6 Abalone

Abalone
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 01 September 2006 - 06:37 PM

AND

admin_transact.php

<?php
require('config.php');
require('class.SimpleMail.php5');

$conn = mysql_connect(SQL_HOST, SQL_USER, SQL_PASS)
or die('Could not connect to Mysql Database. ' . mysql_error());

mysql_select_db(SQL_DB, $conn);

if (isset($_POST['action'])) {
switch ($_POST['action']) {
case 'Add New Mailing List':
$sql = "INSERT INTO ml_lists (listname) " .
  "VALUES ('" . $_POST['listname'] . "')";
mysql_query($sql)
or die('Could not add mailing list. ' . mysql_error());
$sql = "DELETE FROM ml_subscriptions " .
  "WHERE ml_id=" . $_POST["ml_id"];
    mysql_query($sql)
or die('Could not delete mailing list subscriptions. ' .
mysql_error());
break;

case 'Send Message':
if (isset($_POST['msg'], $_POST['ml_id']))  {
if (is_numeric($_POST['ml_id'])) {
$sql = "SELECT listname FROM ml_lists " .
  "WHERE ml_id='" . $_POST["ml_id"] . "'";
$result = mysql_query($sql, $conn)
or die (mysql_error());
$row = mysql_fetch_array($result);
$listname = $row['listname'];
}  else  {
    $listname = "Master";
}

$sql = "SELECT DISTINCT usr.email, usr.firstname, usr.user_id " .
  "FROM ml_users usr " .
  "INNER JOIN ml_subscriptions mls " .
  "ON usr.user_id = mls.user_id " .
  "WHERE mls.pending=0";
    if ($_POST['ml_id'] !='all') {
  $sql .= " AND mls.ml_id=" . $_POST['ml_id'];
}

$result = mysql_query($sql)
  or die('Could not get list of email addresses. ' . mysql_error());

$headers = "From: " . ADMIN_EMAIL . "\r\n";

while ($row = mysql_fetch_array($result)) {
if (is_numeric($_POST['ml_id'])) {
$ft = "You are recieving this message as a member of the ";
$ft .= $listname . "\n mailing list. If you have recieved ";
$ft .= "this email in error, or would like to\n remove your";
$ft .= "name from this mailing list, please visit the ";
$ft .= "following URL:\n";
$ft .= "http://" . $_SERVER['HTTP_HOST'] .
  dirname($_SERVER['HTTP_HOST']) . "/remove.php?u=" .
  $row['user_id'] . "&ml=" . $_POST['ml_id'];
} else {

$ft = "You are recieving this email because you subscribed ";
$ft = "to one or more\n mailing lists. Visit the following ";
$ft = "URL to change your subscriptions:\n";
$ft = "http://" . $_SERVER['HTTP_HOST'] .
  dirname($_SERVER['PHP_SELF']) . "/user.php?u=" .
  $row['user_id'];
}

$msg = stripslashes($_POST['msg']) . "\n\n";
$msg .= "_______________\n";
$msg .= $ft;

$email = new SimpleMail();

$email->send($row['email'],
stripslashes($_POST['subject']),
$msg,
$headers)
or die('Could not send email.');
}
}
break;
}


}

header('Location: admin.php');
?>

#7 HeyRay2

HeyRay2
  • Members
  • PipPipPip
  • Advanced Member
  • 223 posts

Posted 01 September 2006 - 06:47 PM

Comment out this line in your admin_transact.php file, and post back if you still get the header error:

header('Location: admin.php');

NOTE: You may be stuck at a blank page when you comment this out, but this will get us on the right track on what is causing your header error.

;)

#8 Abalone

Abalone
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 01 September 2006 - 08:02 PM

Yep, That works, no header error but im on a blank page.

#9 Abalone

Abalone
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 01 September 2006 - 08:54 PM

I just wanted to say thanks to you Heyray, you are a PHP king

#10 Abalone

Abalone
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 04 September 2006 - 04:48 PM

Im just checkin in

#11 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 04 September 2006 - 10:30 PM

for one they are retarded, you never need anything other than .php, as for your problem, the blank page, based on your php.ini settings can be caused by your error handling setup, like he said get the info.php file up and running, and then send a link to the page, so we can look at your error handling information.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#12 Abalone

Abalone
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 04 September 2006 - 11:28 PM

Ok,

here is the one with just .php

http://cmhwebservice...m/mail/info.php

and here is .php5

http://cmhwebservice.../mail/info.php5

thank you so much!  :D

#13 Abalone

Abalone
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 05 September 2006 - 09:24 PM

Checking in..thanks




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users