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

  • SEARCH
  • Home
  • 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 6983065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:22:13+00:00 2026-05-27T18:22:13+00:00

Haven’t really create my own function before, so what I am attempting is to

  • 0

Haven’t really create my own function before, so what I am attempting is to start the scripts below the line function NewsUpdate, but I want them to be apart of the function. In the if statement, when the script finds the string “News Update” in the ’email message’ it will start those scripts, if not (the else statement all the way at the bottom) it will fail and say “News Update not found in e-mail message”

But I get the error:

Parse error: syntax error, unexpected T_FUNCTION

What am I doing wrong?

// Test code for email message.
$open_email_msg =  file_get_contents('emailmessage.html');

// A script that searches the e-mail for the string News Update,
// and if it is found it will start the function NewsUpdate

if(strpos($open_email_msg,"News Update"))
    function NewsUpdate ($open_email_msg) {
        // Login to MySQL Datebase
        $hostname = "localhost";
        $db_user = "user";
        $db_password = "pass";
        $database = "tablename";
        $db_table = "bx_news_entries";
        $db = mysql_connect($hostname, $db_user, $db_password);
        mysql_select_db($database,$db);
        $subject = 'Test News Article';
        $tags = str_replace(' ',',',$subject); // DDIE
        $uri =  str_replace(' ','-',$subject); // DDIE
        $when = strtotime("now");    // date article was posted
        $categories = 'Events';
        $content = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.';
        $snippet = 'Lorem ipsum dolor sit amet.';
        // $snippet = explode(".", $content, -1);
        # THIS CODE WILL TELL MYSQL TO INSERT THE DATA FROM THE EMAIL INTO YOUR MYSQL TABLE
        $sql = "INSERT INTO $db_table(`caption`, `snippet`, `content`, `when`, `uri`, `tags`, `categories`, `DATE`) values ('$subject', '$snippet', '$content', '$when', '$uri', '$tags', '$categories', '$when')";
        if($result = mysql_query($sql ,$db)) {
        } else {
            echo "ERROR: ".mysql_error();
        }
        echo "<h1>News Article added!</h1>";
    }

else {
    echo "<h3>'News Update</h3>not found in e-mail message!";
}
  • 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-05-27T18:22:14+00:00Added an answer on May 27, 2026 at 6:22 pm

    move your function above and call it:

    function NewsUpdate ($open_email_msg) {
        //function declaration
    }
    
    //Test code for email message.
    
    $open_email_msg =  file_get_contents('emailmessage.html');
    
    //A script that searches the e-mail for the string News Update, and if it is found it will start the function NewsUpdate
    
    if(strpos($open_email_msg,"News Update"))
        NewsUpdate ($open_email_msg);
    else {
    
        echo "<h3>'News Update</h3>not found in e-mail message!";
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I haven't found any documentation on this or seen this done before, but is
Haven't seen anything, but I have seen that you can create albums in the
Haven't fired up reflector to look at the difference but would one expect to
Haven't seen anything about it here but it seems to solve one of the
I haven't touched sharepoint in years. If I want to setup a development environment
I haven't seen any questions relating to GNU autoconf/automake builds, but I'm hoping at
I haven't done a lot of .NET programming, but I've examined a few of
I haven't done a lot of work with multi-level, pure CSS drop-down menus before,
Haven't found what i'm looking for so far. I want to redirect all my
I haven't been able to find documentation that talk about how create.js.erb and destroy.js.erb

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.