By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,537 Members | 1,471 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,537 IT Pros & Developers. It's quick & easy.

My Update function cannot successful update to sql table even don't have any error.

P: 2
My Update function cannot successful update to sql table even don't have any error. Please help to check .....thx


PHP1

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. require_once 'header.php';
  3. ?>
  4. <style type="text/css">
  5. <!--
  6. .style1 {
  7.     font-size: 24px;
  8.     font-family: "Times New Roman", Times, serif;
  9.     color: #FF0000;
  10. }
  11. .style7 {color: #FF0000}
  12. .style8 {color: #000000}
  13. .style10 {color: #000066}
  14. .style11 {color: #0000FF}
  15. .style12 {font-size: 24px}
  16. -->
  17. </style>
  18.  
  19.  
  20.       <table width="507" height="122" border="5" align="center" bordercolor="#00FFFF">
  21.       <tr>
  22.             <td width="497"><div align="center" class=" style11 style12">Edit  Administrator's Information </div></td>
  23.       </tr>
  24.       <tr>
  25.               <form action="customeredit1.php" method="post" name="form1" id="form1">
  26.                 <td width="497" bordercolor="#00FFFF"><div align="center">
  27.                     <p class="style2"> <span class="style8">Insert Product Order's Customer Name To Modify The Information </span><br />
  28.                         <input name="txt1" type="text" id="txt1" size="50" maxlength="60" />
  29.                     </p>
  30.                   <p class="style2">
  31.                       <input name="button2" type="submit" id="button2" value="Search" />
  32.                   </p>
  33.                   <p class="style2"><span class="style2 style7">*<span class="style10">User can't modify the customer's name in this page! </span>*</span></p>
  34.                 </div></td>
  35.             </form>
  36.       </tr>
  37.     </table>
  38. <p align="center"><a href=adminpage.php>Click here  back to Main Menu</a></p>
  39.  
  40.       <p align="center" class="style1">
  41.         <?php
  42. require_once 'footer.php';
  43. ?>
  44.       </p>
PHP2

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. require_once 'header.php';
  3. ?>
  4.  
  5. <style type="text/css">
  6. <!--
  7. .style12 {
  8.     font-weight: bold;
  9.     font-family: Arial, Helvetica, sans-serif;
  10. }
  11. .style16 {color: #CC0000}
  12. .style5 {font-family: Arial, Helvetica, sans-serif}
  13. .style19 {color: #FF0000}
  14. .style20 {color: #000066}
  15. .style17 {font-size: 12px}
  16. .style22 {font-family: Arial, Helvetica, sans-serif; font-weight: bold; font-size: 12px; }
  17. -->
  18. </style>
  19. <form name="form1" method="post" action="customeredit2.php">
  20. <table width="717" border="1" align="center">
  21.             <?php
  22.             $txt = $_POST["txt1"];
  23.  
  24.             $sql = "SELECT * from mailnow where customerid LIKE '%$txt%'";
  25.             $result = mysql_query($sql)
  26.                    or die("SQL select statement failed");
  27.  
  28.             $record=mysql_num_rows($result);
  29.  
  30.                 if ($txt == "")
  31.                 {
  32.                     echo'
  33.                     <SCRIPT LANGUAGE="JavaScript">
  34.                         window.alert("Please insert name!");
  35.                     </SCRIPT>';
  36.                     require "customeredit.php";
  37.                     return;
  38.                 }
  39.  
  40.                 elseif ($record==0)
  41.                 {
  42.                     echo'
  43.                     <SCRIPT LANGUAGE="JavaScript">
  44.                         window.alert("Record not found!");
  45.                     </SCRIPT>';
  46.                     require "customeredit.php";
  47.                     return;
  48.                 }
  49.  
  50.                 elseif ($record)
  51.                 {
  52.                     while ($row = mysql_fetch_array($result))  
  53.                     {
  54.                         $product = $row["product"];
  55.                         $mailtype = $row["mailtype"];
  56.                         $mailboxes = $row["mailboxes"];
  57.                         $price= $row["price"];
  58.                         $name= $row["name"];
  59.                         $company = $row["company"];
  60.                         $department = $row["department"];
  61.                         $address1 = $row["address1"];
  62.                         $address2 = $row["address2"];
  63.                         $city = $row["city"];
  64.                         $state = $row["state"];
  65.                         $zip = $row["zip"];
  66.                         $email = $row["email"];
  67.                         $contact = $row["contact"];
  68.  
  69.                     }
  70.                 }
  71.             ?>
  72.   <tr>
  73.     <td width="207" align="left" bgcolor="#9999FF"><div align="left" class="style22">Product Information </div></td>
  74.     <td width="494" bgcolor="#9999FF"><div align="left"><?php echo("<input name='product' type='text' value='$product' size='60'/>") ; ?></div></td>
  75.   </tr>
  76.   <tr>
  77.     <td align="left" bgcolor="#9999FF"><div align="left" class="style22">Type</div></td>
  78.     <td bgcolor="#9999FF"><div align="left"><?php echo("<input name='mailtype' type='text' value='$mailtype' size='60'/>") ; ?></div></td>
  79.   </tr>
  80.   <tr>
  81.     <td align="left" bgcolor="#9999FF"><span class="style22">No. of mailboxes / No.of computers : </span></td>
  82.     <td bgcolor="#9999FF"><?php echo("<input name='mailboxes' type='text' value='$mailboxes' size='60'/>") ; ?></td>
  83.   </tr>
  84.   <tr>
  85.     <td align="left" bgcolor="#9999FF"><span class="style22">Price </span></td>
  86.     <td bgcolor="#9999FF"><?php echo("<input name='price' type='text' value='$price' size='60'/>") ; ?></td>
  87.   </tr>
  88.   <tr>
  89.     <td align="left" bgcolor="#9999FF"><span class="style22">Name </span></td>
  90.     <td bgcolor="#9999FF"><?php echo("<input name='name' type='text' value='$name' size='60'/>") ; ?></td>
  91.   </tr>
  92.   <tr>
  93.     <td align="left" bgcolor="#9999FF"><span class="style22">Company</span></td>
  94.     <td bgcolor="#9999FF"><?php echo("<input name='company' type='text' value='$company' size='60'/>") ; ?></td>
  95.   </tr>
  96.   <tr>
  97.     <td align="left" bgcolor="#9999FF"><span class="style22">Department</span></td>
  98.     <td bgcolor="#9999FF"><?php echo("<input name='department' type='text' value='$department' size='60'/>") ; ?></td>
  99.   </tr>
  100.   <tr>
  101.     <td align="left" bgcolor="#9999FF"><div align="left" class="style22">Address 1</div></td>
  102.     <td bgcolor="#9999FF"><div align="left"><?php echo("<input name='address1' type='text' value='$address1' size='60'/>") ; ?></div></td>
  103.   </tr>
  104.   <tr>
  105.     <td align="left" bgcolor="#9999FF"><div align="left" class="style22"><strong>Address 2</strong></div></td>
  106.     <td bgcolor="#9999FF"><div align="left"><?php echo("<input name='address2' type='text' value='$address2' size='60'/>") ; ?></div></td>
  107.   </tr>
  108.   <tr>
  109.     <td align="left" bgcolor="#9999FF"><span class="style22">City</span></td>
  110.     <td bgcolor="#9999FF"><?php echo("<input name='city' type='text' value='$city' size='60'/>") ; ?></td>
  111.   </tr>
  112.   <tr>
  113.     <td align="left" bgcolor="#9999FF"><span class="style22">State</span></td>
  114.     <td bgcolor="#9999FF"><?php echo("<input name='state' type='text' value='$state' size='60'/>") ; ?></td>
  115.   </tr>
  116.   <tr>
  117.     <td align="left" bgcolor="#9999FF"><span class="style22">Zip</span></td>
  118.     <td bgcolor="#9999FF"><?php echo("<input name='zip' type='text' value='$zip' size='60'/>") ; ?></td>
  119.   </tr>
  120.   <tr>
  121.     <td align="left" bgcolor="#9999FF"><span class="style22">E-mail </span></td>
  122.     <td bgcolor="#9999FF"><?php echo("<input name='email' type='text' value='$email' size='60'/>") ; ?></td>
  123.   </tr>
  124.   <tr>
  125.     <td align="left" bgcolor="#9999FF"><span class="style22">Contact Number</span></td>
  126.     <td bgcolor="#9999FF"><?php echo("<input name='contact' type='text' value='$contact' size='60'/>") ; ?></td>
  127.   </tr>
  128. </table>
  129.         <p align="center"><span class="style19">*</span> <span class="style20">This page cannot modify the administrator's name. </span><span class="style19">*</span> </p>
  130.         <div align="center">
  131.           <input type="submit" name="submit" value="MODIFY">
  132.           <input type="reset" name="Submit2" value="RESET">
  133.           <input type="submit" name="submit" value="CANCEL" />
  134.       </div>
  135. </form>
  136.  
  137. <?php
  138. require_once 'footer.php';
  139. ?>
PHP3

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. require_once 'header.php';
  3. ?>
  4.  
  5. <?php
  6.  
  7.     $product = $_POST["product"];
  8.     $mailtype = $_POST["mailtype"];
  9.     $mailboxes = $_POST["mailboxes"];
  10.     $price = $_POST["price"];
  11.     $name = $_POST["name"];
  12.     $company = $_POST["company"];
  13.     $department = $_POST["department"];
  14.     $address1 = $_POST["address1"];
  15.     $address2 = $_POST["address2"];
  16.     $city = $_POST['city'];
  17.     $state = $_POST['state'];
  18.     $zip = $_POST['zip'];
  19.     $email = $_POST['email'];
  20.     $contact = $_POST['contact'];
  21.     $submit = $_POST['submit'];
  22.  
  23.     $sql = "SELECT * from mailnow where customerid = '$customerid'";
  24.     $result = mysql_query($sql) or die("SQL select statement failed!");
  25.     $result=mysql_query($sql);
  26.  
  27.     if ($submit=="MODIFY")
  28.     {
  29.         $sql = "UPDATE  mailnow SET product='$product', mailtype='$mailtype', mailboxes='$mailboxes', price='$price' , name='$name' where customerid = '$customerid'";
  30.         $result = mysql_query($sql) or die("SQL select statement failed");
  31.  
  32.         if ($result)
  33.         {
  34.             require "customeredit.php";
  35.             echo'
  36.             <SCRIPT LANGUAGE="JavaScript">
  37.             window.alert ("Updated Success !!!");</SCRIPT>';
  38.         }
  39.         else   { die(mysql_error()); }
  40.     }    
  41.  
  42.     elseif ($submit=="CANCEL")
  43.     {
  44.         require "customeredit.php";
  45.     }
  46.  
  47.     else   { die(mysql_error()); }
  48.  
  49. ?>
  50. <?php
  51. require_once 'footer.php';
  52. ?>
Nov 9 '09 #1
Share this Question
Share on Google+
3 Replies


Atli
Expert 5K+
P: 5,058
Hey.

Try turning the error messages on.
That should help you pinpoint the problem.

Post the errors you get here if you are having trouble fixing them.
Nov 9 '09 #2

P: 2
dun hv any error msg..... :(
Nov 9 '09 #3

Dormilich
Expert Mod 5K+
P: 8,639
the only thing on my mind is that the customerid is invalid, so that the update query is not matching any dataset (but it would not return false, since the query was successful)

try mysql_affected_rows()
Nov 9 '09 #4

Post your reply

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