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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:34:21+00:00 2026-05-15T23:34:21+00:00

guys, i have these codes for updating the records in the database. please.. check

  • 0

guys, i have these codes for updating the records in the database.

please.. check if these is correct?

<?php
session_start(); 
include "db.php"; 

$username = $_SESSION['username'];


$query="SELECT * FROM members where username='".mysql_real_escape_string($username)."'";

$result=mysql_query($query);
$num=mysql_numrows($result);

mysql_close();


$userid             =mysql_result($result,$i, 'userid');
$firstname          =mysql_result($result,$i,'firstname');
$lastname           =mysql_result($result,$i,'lastname');
$username           =mysql_result($result,$i,'username');
$email              =mysql_result($result,$i,'email');
$age                =mysql_result($result,$i,'age');
?>

<form action="update.php" method="post">
<input type="hidden" name="u_userid" value="<? echo "$userid" ?>">
<table>
<tr><td>ID:</td> <td><? echo "$userid"?></td></tr>
<tr><td>First Name:</td> <td> <input type="text" name="u_firstname" value="<? echo "$firstname"?>"></td></tr>
<tr><td>Last Name: </td> <td><input type="text" name="u_lastname" value="<? echo "$lastname"?>"></td></tr>
<tr><td>Username:</td> <td> <input type="text" name="u_username" value="<? echo "$username"?>"></td></tr>
<tr><td>Email:</td> <td> <input type="text" name="u_email" value="<? echo "$email"?>"></td></tr>
<tr><td>Age: </td> <td><input type="text" name="u_age" value="<? echo "$age"?>"></td></tr>
<tr><td></td><td><input type="Submit" value="Update Info">
</td></tr>
</form>
<tr><td></td><td><form action="form2.html" method="post">
<input type="submit" value="Cancel"></form></td></tr>
</table

and in update.php

<?php
session_start(); 
include "db.php"; 

$userid             =mysql_result($result, 'userid');
$firstname          =mysql_result($result, 'firstname');
$lastname           =mysql_result($result, 'lastname');
$username           =mysql_result($result, 'username');
$email              =mysql_result($result, 'email');
$age                =mysql_result($result, 'age');

include "db.php"; 

$query="UPDATE members SET firstname='$u_firstname' , lastname='$u_lastname', username='$u_username' , email='$u_email', age='$u_age' ";

$result=mysql_query($query);


mysql_close();

echo "Record Updated
 <br><br>

<form action=\"form2.html\" >
<input type=\"submit\" value=\"ok!\" />
</form>
";

?>

actually it shows a lot of errors/warning like this

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\web\htdocs\salome\this\update.php on line 7

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\web\htdocs\salome\this\update.php on line 8

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\web\htdocs\salome\this\update.php on line 9

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\web\htdocs\salome\this\update.php on line 10

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\web\htdocs\salome\this\update.php on line 11

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\web\htdocs\salome\this\update.php on line 12

WHAT WILL I DO..

please help me… 🙁

  • 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-15T23:34:22+00:00Added an answer on May 15, 2026 at 11:34 pm

    You are trying to get a result from the database (but even without executing a query) while you have to use edited data from the form via $_POST array

    <?php
    session_start(); 
    include "db.php"; 
    
    $user_id   = mysql_real_escape_string($_SESSION['userid']);
    
    $firstname = mysql_real_escape_string($_POST['u_firstname']);
    $lastname  = mysql_real_escape_string($_POST['u_lastname']);
    $lastname  = mysql_real_escape_string($_POST['u_lastname']);
    $username  = mysql_real_escape_string($_POST['u_username']);
    $email     = mysql_real_escape_string($_POST['u_email']);
    $age       = mysql_real_escape_string($_POST['u_age']);
    //etc
    
    $query     = "UPDATE members SET firstname='$firstname', lastname='$lastname',
                                 username='$username' , email='$email', age='$age' 
                  WHERE userid = '$user_id'";
    
    $result    = mysql_query($query) or trigger_error(mysql_error().$query);
    

    Note that user identification should come from a SESSION, not FORM
    And you should never edit user id.

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

Sidebar

Related Questions

I have a system which will return all users from the database and order
This seems like a simple problem but I have a coder's mental block: The
Say I have the following method: void UpdateContentMethodA(Int32[] src, Int32[] dst) { for(int i=0;
I'm trying to minimize the number of vbs files that I have for a
I am trying to generate java file from wsdlurl. some of them are working
Is there a way to integrate Visual Studio 2010 Coded UI Test with Specflow?
One of the problems of C++ are horrible error messages that we are getting
So it's late here, and my google skills seem to be failing me. I've
I'm currently needing to extend a class to add functionality to it (I do
I am using Jquery load() to load external pages inside a DIV, so far

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.