473,663 Members | 2,726 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 2302
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
3263
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
4950
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
3342
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
17004
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
5973
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
5082
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
2478
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
3952
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
8771
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8548
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
7371
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6186
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
5657
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
4182
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
4349
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2000
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1757
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.