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);
?>

Recommended Answers

All 2 Replies

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.