Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8784151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:01:05+00:00 2026-06-13T21:01:05+00:00

I have a script that send emails to multiple email addresses, the script is

  • 0

I have a script that send emails to multiple email addresses, the script is suppose to redirect to a success page upon completion, the emails are being sent fine with no problems, however I am getting up the following error instead of redirection.

Fatal error: Cannot redeclare spamcheck() (previously declared in
/websites/123reg/LinuxPackage22/br/ig/ht/MYSITE.co.uk/public_html/admin/mailinglistsend.php:87)
in
/websites/123reg/LinuxPackage22/br/ig/ht/MYSITE.co.uk/public_html/admin/mailinglistsend.php
on line 87

The code is as follows

<?php
//initialize the session
if (!isset($_SESSION)) {
  session_start();
}

require_once('../Connections/BrightLights.php'); 

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_BrightLights, $BrightLights);
$query_mailinglist = "SELECT * FROM mailing_list WHERE subscribed = ''";
$mailinglist = mysql_query($query_mailinglist, $BrightLights) or die(mysql_error());
$row_mailinglist = mysql_fetch_assoc($mailinglist);
$totalRows_mailinglist = mysql_num_rows($mailinglist);

error_reporting(E_ALL & ~E_NOTICE);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);




?>
<?php 



$subject = $_POST['subject'];
$body = $_POST['body'];

do {

$name = $row_mailinglist['name'];
$email = $row_mailinglist['email'];



    $email_from = 'mailinglist@MYSITE.com';
    $email_subject = "$subject";
    $email_body = "
    $name,

    $body



    You have received this email because you have subscribed via our website, to unsubscribe go to MYSITE/mailing-list.php?unsubscribe=$email";


    $to = "$email";
    $headers = "From: $email_from";
    mail($to, $email_subject, $email_body, $headers);





    function spamcheck($field)
    {
        //filter_var() sanitizes the e-mail
        //address using FILTER_SANITIZE_EMAIL
        $field=filter_var($field, FILTER_SANITIZE_EMAIL);

        //filter_var() validates the e-mail
        //address using FILTER_VALIDATE_EMAIL
        if(filter_var($field, FILTER_VALIDATE_EMAIL))
        {
            return TRUE;
        }
        else
        {
            return FALSE;
        }
    }

    } while ($row_mailinglist = mysql_fetch_assoc($mailinglist));


mysql_free_result($mailinglist);

    header('Location: mailinglist-new.php?sent');

?>

I appreciate your help 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T21:01:06+00:00Added an answer on June 13, 2026 at 9:01 pm

    strange you are declaring function inside of do while loop

    fixed code should look something like this:

    <?php
    //initialize the session
    if (!isset($_SESSION)) {
      session_start();
    }
    
    require_once('../Connections/BrightLights.php'); 
    
    function spamcheck($field)
        {
            //filter_var() sanitizes the e-mail
            //address using FILTER_SANITIZE_EMAIL
            $field=filter_var($field, FILTER_SANITIZE_EMAIL);
    
            //filter_var() validates the e-mail
            //address using FILTER_VALIDATE_EMAIL
            if(filter_var($field, FILTER_VALIDATE_EMAIL))
            {
                return TRUE;
            }
            else
            {
                return FALSE;
            }
        }
    
    
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
    {
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      }
    
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
    
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;    
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      }
      return $theValue;
    }
    }
    
    mysql_select_db($database_BrightLights, $BrightLights);
    $query_mailinglist = "SELECT * FROM mailing_list WHERE subscribed = ''";
    $mailinglist = mysql_query($query_mailinglist, $BrightLights) or die(mysql_error());
    $row_mailinglist = mysql_fetch_assoc($mailinglist);
    $totalRows_mailinglist = mysql_num_rows($mailinglist);
    
    error_reporting(E_ALL & ~E_NOTICE);
    ini_set('display_errors', TRUE);
    ini_set('display_startup_errors', TRUE);
    
    
    
    
    
    
    $subject = $_POST['subject'];
    $body = $_POST['body'];
    
    do {
    
    $name = $row_mailinglist['name'];
    $email = $row_mailinglist['email'];
    
    
    
        $email_from = 'mailinglist@brightlightstheatreschool.com';
        $email_subject = "$subject";
        $email_body = "
        $name,
    
        $body
    
    
    
        You have received this email because you have subscribed via our website, to unsubscribe go to brightlightstheatreschool.com/mailing-list.php?unsubscribe=$email";
    
    
        $to = "$email";
        $headers = "From: $email_from";
        mail($to, $email_subject, $email_body, $headers);
    
        } while ($row_mailinglist = mysql_fetch_assoc($mailinglist));
    
    
    mysql_free_result($mailinglist);
    
        header('Location: mailinglist-new.php?sent');
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple script that will send out a bunch of emails but
I have a script that uses PHP mail() function to send emails: mail(me@mydomain.com, Subject,
I have a target in my build script that will send an email with
I have a page that sends emails to customers. It has a send all
On a client server, we have a little script that send an email at
I have a few scripts that send out emails to my users, and for
I have a bash script that uses growlnotify to send notifications. However, growlnotify doesn't
I have a simple Python script that uses the socket module to send a
I have an multi-dimensional array that I want to send to a PHP script
I have a need for a simple html + javascript page that must send

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.