473,226 Members | 1,239 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,226 software developers and data experts.

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

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
3 2279
Atli
5,058 Expert 4TB
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
dun hv any error msg..... :(
Nov 9 '09 #3
Dormilich
8,658 Expert Mod 8TB
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

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

Similar topics

3
by: laurie | last post by:
Hi all, I'm trying to help out a friend who has inherited a client with a PHP shopping cart application. Neither of us know PHP, but I've been muddling my way through, trying to get these old...
9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
8
by: Jan van Veldhuizen | last post by:
The UPDATE table FROM syntax is not supported by Oracle. I am looking for a syntax that is understood by both Oracle and SqlServer. Example: Table1: id name city ...
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
18
by: Bill Smith | last post by:
The initial row is inserted with the colPartNum column containing a valid LIKE pattern, such as (without the single quotes) 'AB%DE'. I want to update the column value with the results of a query...
1
by: Bennett Haselton | last post by:
Suppose I add a new row to a table in a dataset, and then I use an OleDbDataAdapter to add that new row to a SQL Server database using OleDbDataAdapter.Update(), as in the following code: ...
4
by: barcaroller | last post by:
I am trying to adopt a model for calling functions and checking their return values. I'm following Scott Meyer's recommendation of not over-using exceptions because of their potential overhead. ...
3
by: Michel Esber | last post by:
Hi all, DB2 V8 LUW FP 15 There is a table T (ID varchar (24), ABC timestamp). ID is PK. Our application needs to frequently update T with a new value for ABC. update T set ABC=? where ID...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.