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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:18:19+00:00 2026-06-15T19:18:19+00:00

I have a php page which extracts data from a dbms which contains email

  • 0

I have a php page which extracts data from a dbms which contains email addy. This works. It then displays the email addy and other stored data data. The user then has the option of putting an “X” in a field designed in the php page called emailselected. This also works. I now want to update the dbms with the new field based on the stored email addy but the update statement doesn’t work. Please help. This portion of the php file is here.

    include("db.php");
if (isset($_POST['ssubmit']))
    {
    $id_save = $test['id'];
    $emailselected_save = $_POST['emailselected'];
    $email_save = $test['email'];

    mysql_query("UPDATE emails SET selected='$emailselected_save' WHERE id = 'id'");
    echo "<input type='button' value='Email(s) sent' onclick='goBack()' />";
mysql_close($conn);
    } else {echo "hello";}
?>
</head>
<form method='post'>
    <div id='headd'>
    <br />
    <input type='button' value='Close this window without Sending' onclick='goBack()' />
    <input type='submit' name='ssubmit' id='ssubmit' value='Send Email Now!!!' />
    <p>Place an "X" in the emails you wish to send!!!</p>
    </div>
    <body>
        <br /><br/>

<?php
    include("db.php");  
    $result = mysql_query("SELECT * FROM emails WHERE unsubscribe  != 'x' ORDER BY lastname ASC");
            while($test = mysql_fetch_array($result))
            {
?>
    <table border='1' width='78%'>
    <tr align=\"left\">
        <td width='4%'><font color='black'><input type='text' size='1' id='emailselected' name='emailselected' /></font></td>
        <td width='15%'><font color='black'><?php echo $test['lastname']?></font></td>
        <td width='15%'><font color='black'><?php echo $test['firstname']?></font></td>
        <td width='40%'><font color='black'><?php echo $test['email']?></font></td>
        <td width='4%'><font color='black'><?php echo $test['id']?></font></td>
    </tr>
</table>
<?php
            }
?>
</form>

At the top of the form is an include statement. This works because it extracts the email addy and displays it in the php file.

What am I doing wrong?

  • 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-15T19:18:21+00:00Added an answer on June 15, 2026 at 7:18 pm

    You’re pretty much limited to the following possibilities if the data didn’t update:

    • the statement failed; or
    • the statement affected no rows; or
    • the statement affected the wrong rows.

    To find out which, you should check the return code from mysql_query to see if it failed or not:

    $rc = mysql_query('my hovercraft is full of eels');
    if (!$result) {
        die('What?: ' . mysql_error());
    }
    

    If it didn’t fail, you should then check how many rows it affected with mysql_affected_rows():

    $num = mysql_affected_rows();
    printf("Updated %d rows\n", $num);
    

    Checking return values from functions that return them is good programming practice.

    It might also be a good idea to output or log all those variables that you’re using in the SQL statement to ensure they’re what you think they are.

    And, though it should go without saying by now, use of the mysql_* functions are discouraged, you should be using mysqli_* (or PDO) instead.


    And I’ve only just noticed that your hierarchy of HTML elements doesn’t seem quite right. You have effectively:

    <head>
        :
    </head>
    <form>
        :
        <body>
            :
    

    which doesn’t gel for me. I’m not sure that form is valid outside of the body. According to the w3c specs, the html element must contain:

    a head element followed by a body element.

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

Sidebar

Related Questions

I have a php page which displays class schedule data for each user from
I have the following in a .htaccess file redirect 301 /page.php http://domain.com/page Which works
We have an existing PHP page (from an earlier project) which could be described
I have web page in PHP which displays all records in a table. I
I have a page (main.php) which loads content from an external PHP file (rpc.php).
I have a php page which dynamically produces this; ... <select name='sales_id'> <option> <option
This is the page that uses this code. I have a php page which
I have a php page which contains a large amount of HTML in it.
I have a PHP page which interacts with this small MySQL database table with
I have a PHP page which accepts input from user in a text area.

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.