# updating profile information(mysql database)

**URL:** <https://www.phphelp.com/t/updating-profile-information-mysql-database/16819>\
**Category:** General Database (Oracle, SQL Server, etc)\
**Created:** [April 29, 2012, 5:44pm UTC](https://www.phphelp.com/t/updating-profile-information-mysql-database/16819 "2012-04-29T17:44:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![suchait](https://www.phphelp.com/letter_avatar_proxy/v4/letter/s/ebca7d/32.png) [@suchait](https://www.phphelp.com/u/suchait)\
**Post date:** [April 29, 2012, 5:44pm UTC](https://www.phphelp.com/t/updating-profile-information-mysql-database/16819/1 "2012-04-29T17:44:46Z")

</div>

i am working on a project  
in which i need to create a option for for editing a user’s profile…  
but getting error now …

update.php (script for present the saved data) :

\<?php include('lock.php'); $host="localhost"; // Host name $username="root"; // Mysql username $password="\*\*\*\*\*"; // Mysql password $db\_name="dailynotes"; // Database name $tbl\_name="userinformation2"; // Table name $user=$login\_session; // Connect to server and select database. mysql\_connect("$host", "$username", "$password")or die("cannot connect"); mysql\_select\_db("$db\_name")or die("cannot select DB"); // get value of id that sent from address bar $id=$\_GET['id']; // Retrieve data from database $sql="SELECT id,firstname,lastname,username,emailid,password FROM $tbl\_name where id='$id' "; $result=mysql\_query($sql); $rows=mysql\_fetch\_array($result); ?\>

| 

| &nbsp; | **Update data in mysql** |
| &nbsp; | &nbsp; | &nbsp; | &nbsp; |
| &nbsp; | **Firstname** | **Lastname** | **username** | **Email** | **Password** | **Update** |
| &nbsp; | | | | | |
| &nbsp; | | | &nbsp; |

 |

\<? // close connection mysql\_close(); ?\>

second file which performs the update in mysql database

update\_ac.php :

\<?php include('lock.php'); $firstname=$\_POST['firstname']; $lastname=$\_POST['lastname']; $username=$\_POST['username']; $email=$\_POST['emailid']; $password=$\_POST['password']; $id=$\_GET['id']; $connection=mysql\_connect("localhost","root","\*\*\*\*") or die("unable to connect with database"); $db=mysql\_select\_db("dailynotes",$connection) or die("unable to find such database"); if(isset($\_REQUEST['submit'])) { $query="UPDATE userinformation2 SET firstname='$firstname',lastname='$lastname',username='$username',emailid='$email',password='$password' where id='$id' "; $result=mysql\_query($query) or die("query failed:".mysql\_error()); if($result) { echo"success"; } } ?\>

check the code …  
help plz…

---

<div class="post-metadata">

**Author:** ![ErnieAlex](https://www.phphelp.com/letter_avatar_proxy/v4/letter/e/bc8723/32.png) [@ErnieAlex](https://www.phphelp.com/u/ErnieAlex)\
**Post date:** [April 30, 2012, 10:14pm UTC](https://www.phphelp.com/t/updating-profile-information-mysql-database/16819/2 "2012-04-30T22:14:34Z")

</div>

We probably can help you. But, what error are you getting and what line is the code stopping at?

Please place code inside of the PHP tags above next time. It is easier for us to copy the code to our editors that way.

Let us know the error you are getting. Thanks…
