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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:56:50+00:00 2026-05-28T03:56:50+00:00

I wonder whether someone could help me please. I’m trying to put together an

  • 0

I wonder whether someone could help me please.

I’m trying to put together an administration form where members records can be amended.

The code that I’ve put together is below and I can successfully retrieve the records from a mySQL database, receiving the appropriate messsage if there are no records with the email address provided.

<?php 
mysql_connect ("host","user","password") or die (mysql_error()); 
mysql_select_db ("database"); 

if ($_SERVER['REQUEST_METHOD'] == 'POST') {  
   if (isset($_POST['search'])) {
      $searchemailaddress = $_POST['searchemailaddress']; 
      $sql = mysql_query("select * from userdetails where emailaddress like '$searchemailaddress'"); 
     if (mysql_num_rows($sql) == 0)
        $msg = 'There are no member records set up with this email address, please try again!'; 
     }
     while ($row = mysql_fetch_array($sql)){ 
        $emailaddress = $row['emailaddress'];
        $forename = $row['forename']; 
        $surname = $row['surname']; 
        $subscriptionexpiration = $row['subscriptionexpiration']; 
     }
   } 
   if (isset($_POST['update'])) {
      $emailaddress = $_POST['emailaddress']; 
      $forename = $_POST['forename']; 
      $surname = $_POST['surname'];
      $subscriptionexpiration = $_POST['subscriptionexpiration']; 
      $sql = mysql_query("UPDATE `userdetails` SET `emailaddress` = '$emailaddress', `forename` = '$forename',`surname` = '$surname',`subscriptionexpiration` = '$subscriptionexpiration' LIMIT 1");
      $msg = 'This members records have been successfully updated!'; 
  }
?>
<html> 
<head> 
<title>Search the Database</title> 
<style type="text/css">
<!--
.style1 {font-family: Calibri
}
.style9 {   font-family: Calibri;
    font-size: 24px;
    background-color: #78AFC5;
}
.style7 {
    font-family: Calibri;
    font-size: 16px;
    background-color: #FFFFFF;
}   
-->
</style>
</head> 
<body> 

  </p>
  <p class="style1">&nbsp;</p>
<div align="center"><span class="style9">Search &amp; Amend User Records </span></div>
<p class="style7"><span class="style10">
  <?php 
if (isset($msg)) // this is special section for 
// outputing message 
{ 
?>
</span>
<p class="style7">
  <?=$msg?>
  <p class="style7"><span class="style10">
  <?php 
} 
?>
  </span>
  <form action="searchandamend.php" method="post">
  <table width="393" border="1">
    <tr>
      <td width="161"><span class="style1">Search:</span></td>
      <td width="207"><span class="style1">
        <input name="searchemailaddress" type="text" id="searchemailaddress" size="25"/>
      </span></td>
    </tr>
    <tr>
      <td><span class="style1">Email Address:</span></td>
      <td><span class="style1">
        <input name="emailaddress" type="text"value="<?php echo $emailaddress;?>" size="25"/>
      </span></td>
    </tr>
    <tr>
      <td><span class="style1">First Name:</span></td>
      <td><span class="style1">
        <input name="forename" type="text" value="<?php echo $forename;?>" size="20"/>
      </span></td>
    </tr>
    <tr>
      <td><span class="style1">Surname:</span></td>
      <td><input name="surname" type="text" value="<?php echo $surname;?>" size="20"/></td>
    </tr>
    <tr>
      <td><span class="style1">Subscription Expiry Date:</span> </td>
      <td><input name="subscriptionexpiration" type="text" id="subscriptionexpiration" value="<?php echo $subscriptionexpiration;?>" size="10"/></td>
    </tr>
  </table>
  <p><br/> 
  <input type="submit" name="search" value="Search Records"> 
  <input name="update" type="submit" value="Update Record"> 
</p>
</form> 
</body> 
</html>

However, I’m having problems when I try to change any part of the record. The changes are saved and I receive the correct ‘Record updated’ message but I also receive this error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /homepages/2/d333603417/htdocs/development/searchandamend.php on line 14 with line 14 being this line in my code: while ($row = mysql_fetch_array($sql)){ I’ve been working on this for a while now, and I just can’t seem to work out what the problem is.

I just wondered whether someone could perhaps take a look at this please and let me know where I’ve gone wrong.

Many 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-05-28T03:56:51+00:00Added an answer on May 28, 2026 at 3:56 am

    All, sincere thanks for taking the time to reply to my post.

    After looking at this a little more, and taking into account what you all said, I came up with the following which works fine.

    if ($_SERVER['REQUEST_METHOD'] == 'POST')  
    {  
        if (isset($_POST["search"]))  
        {  
    $searchemailaddress = $_POST['searchemailaddress'];
    $result = mysql_query("select * from userdetails where emailaddress like '$searchemailaddress'");
    if (mysql_num_rows($result) == 0)
    $msg = 'There are no member records with the email address you have provided, please try again!'; 
    else
    while ($row = mysql_fetch_array($result)){ 
    $emailaddress = $row['emailaddress'];
    $forename = $row['forename']; 
    $surname = $row['surname']; 
    $subscriptionexpiration = $row['subscriptionexpiration']; 
    $msg = 'Record retrieved!';
    }
    }
    
    if (isset($_POST["update"]))  
        {  
    $emailaddress = $_POST['emailaddress']; 
    $forename = $_POST['forename']; 
    $surname = $_POST['surname']; 
    $result = mysql_query("UPDATE `userdetails` SET `emailaddress` = '$emailaddress', `forename` = '$forename',`surname` = '$surname', `subscriptionexpiration` = '$subscriptionexpiration' LIMIT 1");
    $msg = 'This members record has been successfully updated!';
    }
    }
    

    Kind regards

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

Sidebar

Related Questions

I wonder whether someone can help me please. I'm trying to put together a
I wonder whether someone can help me please. I'm trying to put together a
I wonder whether someone could help me please. I have put together a form
I wonder whether someone could help me please. I'm put together the following form
I wonder whether someone can help me please. I've put together this page, which
I wonder whether someone can help me please. I've put together the script below
I wonder whether someone can help me please. I've put together the code below
I wonder whether someone can help me please. I've put together the following which
I wonder whether someone may be able to help me please. I've put together
I wonder whether someone can help me please. I'm trying to implement the mysql_insert_id()

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.