SoilentRed
Caaan do!
I have a form with a textarea element. This element gets formatted and passed through a loop and inserted into a few rows. It works perfectly fine except when the submitter presses [Enter] to start a new line in their message. When the submitter has a new line in their message, I get the following error:
Here's is the OnAfterProcess php plugin code I'm running
It looks like the message gets submitted successfully in all cases to the SMS table, but not the SMSQ table that it's supposed to loop through.
I need to use the ENT_QUOTES decoder because it was converting all my special characters. for example, the "&" symbol was being converted to "&". But I also need to be able to insert a new line in the textarea without it breaking.
Help and guidance are always valued.
Code:
0 - syntax error, unexpected 'test' (T_STRING)
Here's is the OnAfterProcess php plugin code I'm running
Code:
$myDb = JFactory::getDbo();
$myQuery = $myDb->getQuery( true );
$selection = '{sms___which_groups_raw}';
$sels = explode( ",", $selection );
$bad_symbols = array( ",", ".", "-", " " );
$timezone = '{sms___tz}';
$scheduledDateTime = $formModel->getElementData('sms___scheduled_datetime');
$scheduledDateTime = new DateTime($scheduledDateTime);
// $list = array();
// start building the query ..
$myQuery->insert( 'afab_smsq' );
$myQuery->columns(
array(
$myDb->quoteName( 'date_time' ),
$myDb->quoteName( 'f_name' ),
$myDb->quoteName( 'l_name' ),
$myDb->quoteName( 'full_name' ),
$myDb->quoteName( 'message' ),
$myDb->quoteName( 'scheduled_datetime' ),
$myDb->quoteName( 'company' ),
$myDb->quoteName( 'subject' ),
$myDb->quoteName( 'agent_id' ),
$myDb->quoteName( 'mobile' ),
$myDb->quoteName( 'status' )
)
);
foreach ( $sels as $sel ) {
$scheduled = 'CONVERT_TZ(' . $myDb->quote($scheduledDateTime->format('Y-m-d H:i:s')) . ', "+0:00", "'.$timezone.'")';
$insel = ( int )$sel;
$myDb->setQuery( 'SELECT cell_phone, userid, name, first_name, last_name, organization FROM #__acymailing_subscriber JOIN #__acymailing_listsub ON #__acymailing_subscriber.subid = #__acymailing_listsub.subid WHERE #__acymailing_listsub.listid = ' . $insel . ' AND #__acymailing_subscriber.enabled = 1' );
$rows = $myDb->loadObjectList();
foreach ( $rows as $row ) {
$cellphone = str_replace( $bad_symbols, "", $row->cell_phone );
if ( empty( $cellphone ) ) {
} else {
$myQuery->values(
implode( ',',
array(
$myDb->quote( '{sms___date_time}' ),
$myDb->quote($row->first_name),
$myDb->quote($row->last_name),
$myDb->quote($row->name),
$myDb->quote(html_entity_decode( '{sms___message}', ENT_QUOTES | ENT_XML1, 'UTF-8') ),
$scheduled,
$myDb->quote($row->organization),
$myDb->quote( '{sms___subject}' ),
$myDb->quote( '{sms___nia_agent_id}' ),
$myDb->quote($cellphone),
0
)
)
);
}
}
}
// run the query
$myDb->setQuery( $myQuery );
// uncomment this line if you need to debug
// var_dump($myQuery);exit;
$myDb->execute();
It looks like the message gets submitted successfully in all cases to the SMS table, but not the SMSQ table that it's supposed to loop through.
I need to use the ENT_QUOTES decoder because it was converting all my special characters. for example, the "&" symbol was being converted to "&". But I also need to be able to insert a new line in the textarea without it breaking.
Help and guidance are always valued.