Thread subject: Official Home of the PHPFusion CMS :: Why Am I Getting This Error?

Posted by Grimloch on 17-01-2023 18:17
#1

I keep getting undefined array key errors in my newsletter infusion which I modified to work under Fusion 8.00.80... This is the line that gives the error:
Code
   $send_array = ($_POST['send_to']wink;
   $list = implode(",",$send_array);
   $to_email = $list;
   $list_array = explode(",",$to_email);
   reset($list_array);

foreach($list_array AS $to_mail) {

This is the actual array line:
Code
// Select site users single/multiple/all send
   echo "<td class='tbl2' valign='top' align='left'><a href='' class='addspeech' title='".$locale['nl_931']."' rel='#speechbubble4'><img src='images/help.gif' border='0' alt='' /></a><span style='font-size: 17px; font-weight: bold;'>".$locale['nl_464']."</span></td><td class='tbl1' valign='top' align='left'><table cellspacing='0' cellpadding='0' border='0'><tr>n";
   echo "<td valign='top' align='left' width='260'><input type='checkbox' name='delivery' value='um1'".$um1." />".$locale['nl_442']."</td>n";
   echo "<td valign='top' align='center'><select name='send_to[]' multiple='true' size='8' class='textbox' style='width:295px;'>";
   $result = dbquery("SELECT * FROM ".DB_NEWS_LETTER_SUBS." WHERE nl_sub_stat ='1' AND nl_sub_who='1' ORDER BY nl_sub_name"wink;
   if (dbrows($result) != 0) {
   while ($data = dbarray($result)) {
 $selected = (isset($_GET['nl_sub_mail']wink && $_GET['nl_sub_mail'] == $data['nl_sub_mail']wink ? 'selected="selected"' : '';
 echo "<option value='".$data['nl_sub_mail']."'$selected>".$data['nl_sub_name']." - ".$data['nl_sub_mail']."</option>n";
 }
}
   echo "</select></td></tr></table></td>n";
   echo "</tr><tr>n";
// End select site users single/multiple/all send

Am I doing the $send_array line wrong? Should it be like this?
Code
$send_array = (($_POST['send_to']wink);

Edited by Grimloch on 20-01-2023 21:05

Posted by douwe_yntema on 18-01-2023 21:35
#2

Check with var_dump the $POST var.
I
And maybe ad an id to the select in stead of a name only

Posted by Grimloch on 20-01-2023 21:07
#3

[quote name=douwe_yntema post=212058]@douwe_yntema - Check with var_dump the $POST var.
I
And maybe ad an id to the select in stead of a name only[/quote]
I added more of my code. Please check it now.

Posted by Grimloch on 21-01-2023 17:11
#4

OK. I simply added this to the top of my file and I believe it cured my problem:
Code
$send_to = isset($_REQUEST['send_to']wink ? $_REQUEST['send_to'] : "";

Posted by Chan on 22-01-2023 17:03
#5

Glad it worked out, but you can try this shorthand as well that bears the same meaning.
Code
$send_to = $_REQUEST['send_to'] ?? "";


The code above is different than an empty check though which goes like this:

Code
$send_to = !empty($_REQUEST['send_to']wink ? $_REQUEST['send_to'] : '';

Edited by Chan on 22-01-2023 17:04

Posted by Grimloch on 22-01-2023 17:15
#6

Appreciate your input Chan however, there are 3 send sections (routines) in my newsletter script so I ended up wrapping each section with this:
Code
if(isset($_POST['send_to']wink) {
and that seems to work just fine. Better in fact. So now I think I have a very solid newsletter system for Fusion ver8. Should be the same for ver9. With this change I was able to send 100 emails in 105 seconds. Before it would take over 4 minutes.

Edited by Grimloch on 22-01-2023 18:50