We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Parse Error using PEAR

I've been working on some code for a while, and it seems that I have a problem at the moment. The code, to me, looks correct and should work, but while trying to use PEAR to send mail out, it's throwing this error: PHP Parse error: syntax error, unexpected T_STRING in /srv/www/vhosts/fas/administrator/components/com_chronoforms/form_actions/custom_code/custom_code.php(18) : eval()'d code on line 82

Here is my code, and all of its comments made... sanitized from using the emails in the code.

I am aware there is still some code that is being used to test the script. Trying to test it, get it fully functional, then will clean up the code. ANY help would be greatly appreciated.

<?php
require_once("Mail.php");

// Using $form->data[xxxxxx] to store data from the Form array
$name = $form->data[lastName] . ', ' . $form->data[firstName];
$county = $form->data[county];
$address1 = $form->data[streetAddress];
$address2 = $form->data[address2];
$city = $form->data[city];
$state = $form->data[state];
$zipcode = $form->data[zipcode];
$phone = $form->data[phoneNumber];
$email = $form->data[email];
$ssn = $form->data[ssn];
$changes = $form->data[changes];
$additional = $form->data[additionalInfo];

$hostname = 'localhost';
$user = '***';
$password = '***';
$database = '***';

$link = mysqli_connect($hostname,$user,$password,$database) or die("Unable to select database");

$query = "SELECT * FROM tblEmail WHERE county='$county'";

$result = mysqli_query($link,$query) or die("Query error.");

// Statement will add the emails from the array
while ($row = mysqli_fetch_array($result))
{
$emailGroup = $row['emailGroup'];
$emailSupervisor = $row['emailSupervisor'];
}

mysqli_close($link);

$emailGroup = '***';
$emailSupervisor = '***';

$to      = $emailGroup;

$subject = 'Case Changes: ' . $form->data[lastName] . ', ' . $form->data[firstName];

$message = 'User information has been provided as follows:' . "\r\n" . "Name: " . $name . "\r\n";
$message .= 'County Selected: ' . $county . "\r\n";
$message .= 'Address: ' . $address1 . "\r\n";
$message .= $address2 ."\r\n";
$message .= 'City, State, Zip: ' . $city . ', ' . $state;
$message .= ' ' . $zipcode . "\r\n";
$message .= 'Phone Number: ' . $phone . "\r\n";
$message .= 'Email: ' . $email . "\r\n";
$message .= 'Social Security Number: ' . $ssn . "\r\n";
$message .= 'Changes: ' . $changes . "\r\n";
$message .= 'Additional Information: ' . $additional . "\r\n";

/*$headers = 'From: ***' . "\r\n" .
    'Reply-To: ***' . "\r\n" .
    'X-Mailer: PHP/' . phpversion(); */

/* $headers = 'From: ***' . "\r\n" .
    'Reply-To: ***' . "\r\n" .
	'Cc: ' . $emailSupervisor . "\r\n" .
    'X-Mailer: PHP/' . phpversion();*/

$from = "***";
$to = "***";
$subject = "Subject test";

$headers = array ('From' => $from,
   'To' => $to,
   'Subject' => $subject);
	
$host = "***";

$smtp = Mail::factory('smtp', array ('host' => $host));
 
$mail = $smtp->send($to, $headers, $message);

if (PEAR::isError($mail))
{
   die($mail->getMessage());
} 

//mail($to, $subject, $message, $headers);
?>
2
Contributors
2
Replies
1 Day
Discussion Span
1 Year Ago
Last Updated
3
Views
jrcampbell
Newbie Poster
2 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

You are missing some quotes: $form->data[lastName] should be $form->data['lastName'] and so on. Bye.

cereal
Veteran Poster
1,143 posts since Aug 2007
Reputation Points: 344
Solved Threads: 221
Skill Endorsements: 22

You are missing some quotes: $form->data[lastName] should be $form->data['lastName'] and so on. Bye.

While I appreciate the help, that is not where the error is occurring. That data is pulling from an application, and that bit works flawlessly. However, the error is being thrown while attempting to run the If() statement in regards to the use of PEAR.

jrcampbell
Newbie Poster
2 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0860 seconds using 2.72MB