canusbucket
New Member
I'm currently prototyping a concept, so am using PHPMailer to generate/send emails out. I will move to something like SendGrid as somewhat soon, but that is not the issue at the moment. I need to send an email to every user in the DB, but the email will be customized based on elements stored in the DB (specific to the individual user). I have PHPMailer working to pull fields from the DB and sending the mail. However, when I try to add the ability to cycle through all users and generate an email to each one, I seem to be having some PHP/SQL issues. The "users" table has the fields: cid, email, fname, lname. I need to pull the cid to pull other information in the DB and I need the email so I know where to send the message. Here is my SQL/PHP:\[code\]require_once('/PHPMailer_v51/class.phpmailer.php');include $_SERVER['DOCUMENT_ROOT'] . '/NG/includes/db.inc.php';try{$sql = 'SELECT * FROM users';$result = $pdo->prepare($sql);$result->execute();}catch (PDOException $e){$error = 'Error fetching user information.';include 'error.html.php';exit();} foreach ($result as $row); { try { $high_result = $pdo->query('SELECT title FROM book WHERE topic = "high" and cid = $row['cid']'); } catch (PDOException $e) { $error = 'Error fetching fields from database!'; include 'error.html.php'; exit(); } .... the rest of the for statement....\[/code\]I'm getting an unexpected T_STRING error on the $high_result line. The "users" DB has the fields: cid, email, fname, lname. Am I not able to reference an array in the sql statement? If not, any ideas on how I should be trying to do this?Thanks,Twine