473,396 Members | 1,871 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

records are not being updated as well as no error is shown to me............

hi...
i want to update employee's record but its not being updated.....can u help me out....
no error is shown to me.....




Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body bgcolor="pink">
  3. <?
  4. $con=mysql_connect("localhost","root","root");
  5. if (!$con)
  6. {
  7. die('Could not connect: ' . mysql_error());
  8. }
  9. mysql_select_db("master", $con);
  10. $result=mysql_query("select * from emp_company");
  11. echo "<table border='3'> <BR><BR><BR><BR>
  12. <tr>
  13. <th >Employee Code</th>
  14. <th>Name</th>
  15. <th>Company</th>
  16. <th> Shift</th>
  17. <th>DOJ</th>
  18. <th>DOL</th>
  19. <th> Dept</th>
  20. <th> Subdept</th>
  21. <th>ESI Code</th>
  22. <th>P/F</th>
  23. <th>Card No.</th>
  24. <th>Bank A/C No.</th>
  25. </tr>" ;
  26. while($row=mysql_fetch_assoc($result))
  27. {
  28. echo "<tr>";
  29. echo "<td>" . $row['ecode'] . "</td>";
  30. echo "<td>" . $row['ename'] . "</td>";
  31. echo "<td>" . $row['ecom']. "</td>";
  32. echo "<td>" . $row['eshift'] . "</td>";
  33. echo "<td>" . $row['edoj'] . "</td>";
  34. echo "<td>" . $row['edol'] . "</td>";
  35. echo "<td>" . $row['edpt'] . "</td>";
  36. echo "<td>" . $row['esubdpt'] . "</td>";
  37. echo "<td>" . $row['eesicode'] . "</td>";
  38. echo "<td>" . $row['epf'] . "</td>";
  39. echo "<td>" . $row['ecardno'] . "</td>";
  40. echo "<td>" . $row['ebank'] . "</td>";
  41. echo "</tr>";
  42. echo '<a href="update.php?ecode='.$row['ecode'].' ">Update</a> ' ;
  43. }
  44. mysql_close($con);
  45. ?>
  46. </body></html>
  47.  
Expand|Select|Wrap|Line Numbers
  1. <?
  2. mysql_connect("localhost","root","root");
  3. mysql_select_db("master");
  4.  
  5. // ***** This part will process when you Click on "Submit" button *****
  6. // Check, if you clicked "Submit" button
  7. if($_POST['Submit']){
  8.  
  9. // Get parameters from form.
  10. $ecode=$_POST['ecode'];
  11. $ename=$_POST['ename'];
  12. $ecom=$_POST['ecom'];
  13. $eshift=$_POST['eshift'];
  14. $edoj=$_POST['edoj'];
  15. $edol=$_POST['edol'];
  16. $edpt=$_POST['edpt'];
  17. $esubdpt=$_POST['esubdpt'];
  18. $eesicode=$_POST['eesicode'];
  19. $epf=$_POST['epf'];
  20. $ecardno=$_POST['ecardno'];
  21. $ebank=$_POST['ebank'];
  22.  
  23.  
  24. mysql_query("update emp_company set ecode='$ecode', ename='$ename',ecom='$ecom', eshift='$eshift',edpt='$edpt',esubdpt='$esubdpt',edoj='$edoj',edol='$edol',eesicode='$eesicode',epf='$epf',ecardno='$ecardno,ebank='$ebank' where ecode='$ecode'");
  25.  
  26. // Re-direct this page to select.php.
  27. header("location:select.php");
  28. exit;
  29. }
  30. // ************* End update part *************
  31.  
  32. // *** Select data to show on text fields in form. ***
  33.  
  34. // Get id parameter (GET method) from select.php
  35. $ecode=$_GET['ecode'];
  36.  
  37. // Get records in all columns from table where column id equal in $id and put it in $result.
  38. $result=mysql_query("select * from emp_company where ecode='$ecode'");
  39.  
  40. // Split records in $result by table rows and put them in $row.
  41. $row=mysql_fetch_assoc($result);
  42.  
  43. // Close database connection.
  44. mysql_close();
  45. ?>
  46.  
  47. <!-- END OF PHP CODES AND START HTML TAGS -->
  48.  
  49. <html>
  50. <body>
  51. <!-- set this form to POST method and target this form to itself ($PHP_SELF;)-->
  52. <form id="form1" name="form1" method="post" action="<? echo $PHP_SELF; ?>">
  53. <p>code
  54. <input name="ecode" type="text" id="ecode" value="<? echo $row['ecode']; ?>"/>
  55. <p>Name :
  56. <!-- name of this text field is "name" -->
  57. <input name="ename" type="text" id="ename" value="<? echo $row['ename']; ?>"/>
  58. <br />
  59. <p>Company
  60. <input name="ecom" type="text" id="ecom" value="<? echo $row['ecom']; ?>"/>
  61. <p>
  62. <p>shift :
  63. <!-- name of this text field is "email" -->
  64. <input name="eshift" type="text" id="eshift" value="<? echo $row['eshift']; ?>"/>
  65. <br />
  66. <p>DOJ
  67. <input name="edoj" type="text" id="edoj" value="<? echo $row['edoj']; ?>"/>
  68. <p>
  69. <p>DOL :
  70. <!-- name of this text field is "tel" -->
  71. <input name="edol" type="text" id="edol" value="<? echo $row['edol']; ?>"/>
  72. </p>
  73. <p>Dept.
  74. <input name="edpt" type="text" id="edpt" value="<? echo $row['edpt']; ?>"/>
  75. <p>
  76.  
  77. <p>Sub Dept.
  78. <input name="esubdpt" type="text" id="esubdpt" value="<? echo $row['esubdpt']; ?>"/>
  79. <p>
  80. <p>ESICODE
  81. <input name="eesicode" type="text" id="eesicode" value="<? echo $row['eesicode']; ?>"/>
  82. <p>
  83. <p>P/F
  84. <input name="epf" type="text" id="epf" value="<? echo $row['epf']; ?>"/>
  85. <p>
  86. <p>CardNo.
  87. <input name="ecardno" type="text" id="ecardno" value="<? echo $row['ecardno']; ?>"/>
  88. <p>
  89. <p>Bank A/C No.
  90. <input name="ebank" type="text" id="ebank" value="<? echo $row['ebank']; ?>"/>
  91. <p>
  92. <input type="submit" name="Submit" value="Submit" />
  93. </p>
  94. </form>
  95. </body>
  96. </html>
  97.  
Feb 5 '10 #1
1 1437
Atli
5,058 Expert 4TB
@puneetmca
That does not surprise me, since you don't even bother to check the result of your UPDATE query before you redirect the page.

Read this post, specifically the second part regarding the MySQL error messages.
Feb 5 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: | last post by:
Hello, Sorry to ask what is probably a simple answer, but I am having problems updating a table/database from a PHP/ PHTML file. I can Read From the Table, I can Insert into Table/Database, But...
2
by: M Wells | last post by:
Hi All, Just wondering if you perform an update using a where condition that actually returns no rows to be updated, does @@Error contain an error message afterwords? We want to fire an...
0
by: Mike | last post by:
Hello, We are using mysql v4.0.24 on Linux machines. I'm trying to set up replication with a master and only one slave database. The syncronization seems to work well, the relay file on slave...
28
by: Lee Rouse | last post by:
Hello all, This is going to be a rather lengthy "question". I have an Access 2k database, separated front end/back end. Front end copies are on about 30 workstations and used frequently during...
5
by: Lumpierbritches | last post by:
Thank you in advance. I have a database that I've written in Access 97 and have some clients using the program. My question is, when I update tables, so they don't loose their data, is there a way...
1
by: Vladimir Koudela | last post by:
Hi people, I am sure most of you have already solved the Access' stupid problem: there is no simple way of numbring of records shown in a continuous form, needed so often (top-lists, achieved...
16
by: Ian Davies | last post by:
Hello Needing help with a suitable solution. I have extracted records into a table under three columns 'category', 'comment' and share (the category column also holds the index no of the record...
7
by: Ron | last post by:
Hi All, Using Access2000, winXP. Table 1 = tblClients displayed on frmClients via qryClients. 2nd table = tblInvoices shown on frmInvoices via qryInvoices. 2nd table = tblDetails shown on...
2
by: PhilOwens | last post by:
Morning/Afternoon all, Having slight problem with showing users the progress of a query..... Bit of background....The database allows users to view the status of documents i.e. Completion date,...
0
by: KrazyKoder | last post by:
Hello, I have MS Access form that basically allows the user to configure an update statement to a single table via the gui. A requirement is to show the count of records that will be updated...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.