473,836 Members | 1,498 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

2 New Member
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 2326
Atli
5,058 Recognized Expert Expert
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
pinko1204
2 New Member
dun hv any error msg..... :(
Nov 9 '09 #3
Dormilich
8,658 Recognized Expert Moderator Expert
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
3273
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 scripts working on a new server with the most recent version of PHP. I've pretty much taken care of all the various errors that were popping up. Most only pointed out out non-fatal undefined or assumed variables. I've been able to cure most of...
9
4969
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 webserver runs that part of the script (see attached file, snippet.php), though, it doesn't go through. I don't get an error message or anything...it just returns a "1" (whereas it should return a "0") as far as I can tell. I have read the PHP...
8
3356
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 city_id 1 john newyork null
16
17034
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 must be UPDATED, if not, they must be INSERTED. Logically then, I would like to SELECT * FROM <TABLE> WHERE ....<Values entered here>, and then IF FOUND UPDATE <TABLE> SET .... <Values entered here> ELSE INSERT INTO <TABLE> VALUES <Values...
18
5992
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 against a different table (that uses the LIKE predicate) but cannot get around the SQL0132 error . I have tried the hex notation after the LIKE such as (without the quotes)... " where colNewPartNum like ( X'27' || nnn.colPartNum || X'27) " ,...
1
5096
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: dsLocalDataSet.user_postRow newRow = dsLocalDataSet1.user_post.Newuser_postRow(); newRow.post_text = this.lblHiddenMessageStorage.Text; newRow.post_datetime = System.DateTime.Now; dsLocalDataSet1.user_post.Adduser_postRow(newRow);...
4
2486
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. Here's the approach I'm currently looking at. I throw exceptions only from constructors. Destructors, of course, do not throw exceptions. All other functions return a signed integer. The values are all stored in one large header file (as...
3
3978
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 = ?
0
9825
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10846
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10595
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10254
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6979
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5650
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5828
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4021
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.