I have stripped this right down, to try and find the source of this issue, but can not pin point it at all.
This successfully echos each of the IDs
$result = mysqli_query($con,"SELECT id FROM users");
// Each user matching criteria
while($row = mysqli_fetch_array($result))
{
echo $row['id'];
}
However when I include Mandrill it stops working, however I will still get the first ID echo'd
// Search Database for users who signed up yesterday
$result = mysqli_query($con,"SELECT id FROM users");
// Each user matching criteria
while($row = mysqli_fetch_array($result))
{
echo $row['id'];
include($_SERVER['DOCUMENT_ROOT'].'/src/Mandrill.php');
$mandrill = new Mandrill('hidden');
try {
$template_name = $content_template;
$message = array(
'html' => '<p>Example HTML content</p>',
'text' => 'Example text content',
'subject' => 'test',
'from_email' => 'hidden',
'from_name' => 'hidden',
'to' => array(
array(
'email' => 'hidden',
'name' => 'Tim',
'type' => 'to'
)
),
'headers' => array('Reply-To' => 'hidden.com'),
'important' => false,
'track_opens' => true,
'track_clicks' => true,
'tags' => array('$meta_tags'),
'google_analytics_domains' => array('hidden'),
'metadata' => array('website' => 'hidden')
);
$ip_pool = 'Main Pool';
$result = $mandrill->messages->sendTemplate('jotText-Auto-i101-welcome', $template_content, $message, $async, $ip_pool, $send_at);
print_r($result);
} catch(Mandrill_Error $e) {
// Mandrill errors are thrown as exceptions
echo 'A mandrill error occurred: ' . get_class($e) . ' - ' . $e->getMessage();
// A mandrill error occurred: Mandrill_Unknown_Subaccount - No subaccount exists with the id 'customer-123'
throw $e;
}
}
The error message I get is
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, array given in /home/timbaker/public_html/jottext/foundation/database_tasks/cron_welcome.php on line 18
Which suggests to me it is a problem with the original query... But I can't work out why Mandrill causes this to happen?
Also worth noting:
- No error messages from Mandril
- Email does successfully send