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 8936145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:09:09+00:00 2026-06-15T10:09:09+00:00

<html> <body> <?php include ‘index.php’; include ‘../db.php’; $query_email = SELECT email FROM email_addresses; $result_query_email

  • 0
<html>
<body>
<?php

include 'index.php';
include '../db.php';
$query_email = "SELECT email FROM email_addresses"; 
$result_query_email = mysqli_query($query_email)
or die(mysqli_error());

while ($row = mysqli_fetch_array()($result_query_email)) {

//$email_user = $row[10];
$email_user = $row['email'];

$data = date("Y.m.d");
$subject = "Good news";
$message = ("Hello!");

$sentemail = mail($email_user, $subject, $message, 
"From: abc <xyz.com>\nX-Mailer: PHP/" . phpversion());
}
if($sentemail) 
{

    print("Email has been sent successfully.<br>");
}
else
{
  print("There was a problem while sending email.<br>");
}

?>

</body>
</html>

This code is to select email addresses from the database and to send them an email. what is wrong with my code, i can’t get any email, Help will be appreciated. Thanks!

  • 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-15T10:09:10+00:00Added an answer on June 15, 2026 at 10:09 am

    This line here

    while (mysql_fetch_array($result_query_email)
    

    you need to assign the return value of mysql_fetch_array() to a variable to be able to use it in the while() loop as well as the missing closing )

    for instance

    while ($emaildata = mysql_fetch_array($result_query_email)) {
    {
        $email_user = $emaildata['email'];
     //.....rest of code
    

    also

    Please, don’t use mysql_* functions in new code. They are no longer maintained and the deprecation process has begun, see the red box. Learn about prepared statements instead, and use PDO or MySQLi; this article will help you decide which. If you choose PDO, here is a good tutorial.

    EDIT

    Also it seems like you are trying to use the variable as a associative array you need to use mysql_fetch_assoc() instead of mysql_fetch_array() to do that

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Code example; PHP Web Page: (index.php) <html><head></head> <body> <?php include(class_validation.php); $val = new validation();
<html> <body> <?php include './includes/connect_db.php' // connecting to mysql server ?> <?php include './includes/select_db.php'
132 a:4:{s:8:template;a:1:{s:10:index.html;b:1;}s:9:timestamp;i:1256373019;s:7:expires;i:1256373079;s:13:cache_serials;a:0:{}}<body> php<br > java<br > c++<br > </body> Can someone explain this part:
<?php session_start(); // store session data $_SESSION['count']=0; ?> <html><head></head> <body> <?php include (getElement.php); echo
<?php include 'dbFunctions.php'; $courseid = $_GET['Course_id']; $query = SELECT * FROM course WHERE Course_id=.$courseid.;
<?php include 'simple_html_dom.php'; $url = 'http://en.wikipedia.org/wiki/Myst'; $html = file_get_html($url); echo $html->find('body'); ?> This has
I am trying to include a very simple header.html to my index.php but it
If I include an HTML page on a PHP page (say, index.php) with the
So I have this index.php page: <?php include main.php; ?> <html> <head> <link rel=stylesheet
Given: Url - http://www.contoso.com/search.php?q= {param} returns: -html- --body- {...} ---div id='foo'- ----div id='page1'/- ----div

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.