473,770 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unable to update and delete

1 New Member
[PHP]
<?
session_start() ;

require("db.php ");

mysql_connect(M ACHINE, USER, '');
mysql_select_db (DBNAME);

$username = $_SESSION['username'];
$pwd =$_SESSION['pwd'];

if(isset($usern ame)){

$customerid = $_POST['customerid'];
$customername = $_POST['customername'];
$customercontac t = $_POST['customercontac t'];
$orderid = $_POST['orderid'];

$sql = "SELECT * FROM customer";

$result = mysql_query($sq l) or die("Unable to get order info");

$row = mysql_fetch_ass oc($result);
extract($row);

}
?>

<html>
<head>
<title>Update Customer Details</title>
</head>
<body>
<form action="do_upda tecustomer.php? action=do_updat ecustomer&order id=<?php echo $orderid; ?>" enctype="multip art/form-data" method='post'>< br>
<link rel="stylesheet " type="text/css" href="fyp.css" />
<b></b><br><br>
<table border="0">

<tr><td>Custome r Name:</td>
<td><input type="text" name ="customerna me" value ="<?php echo $customername; ?>"></td></tr>

<tr><td>Custome r Contact:</td>
<td><input type="text" name ="customerconta ct" value ="<?php echo $customercontac t; ?>"></td></tr>

<tr><td>Order ID:</td>
<td><input type="text" name ="orderid" value ="<?php echo $orderid; ?>"></td></tr>

<tr><td><inpu t type="reset" value="Reset"></td>
<td><input type = "Submit" name="submit" value="Update"> </td></tr>

</table>
</form>
</body>
</html>


<?

session_start() ;

require("db.php ");

mysql_connect(M ACHINE, USER, '');
mysql_select_db (DBNAME);

if (isset($_POST['submit']))
{
$customerid = $_GET['customerid'];
$customername = $_POST['customername'];
$customercontac t = $_POST['customercontac t'];
$orderid = $_POST['orderid'];


$sql = "UPDATE 'customer' SET 'customername' = '$customername' ,
'customercontac t' = '$customerconta ct','orderid' = '$orderid' WHERE 'customerid' = '$customerid'";

$result = mysql_query($sq l) or die ("Unable to Update Customer Information");
}


//echo "Customer Details has been updated from database.";


//<br><br>
//"<a href=cus_detail s.php>View Customer Details</a><br>";
//"<a href=index.php> Go to Mainpage</a><br>";
?>
[/PHP]

I can't seem to update...Could someone be so kind to help me check my codes =)
Jul 8 '07 #1
2 1757
mwasif
802 Recognized Expert Contributor
Can you explain "it cant seem to update"?

Use this query to update
Expand|Select|Wrap|Line Numbers
  1. $sql = "UPDATE customer SET customername = '$customername',
  2.         customercontact = '$customercontact', orderid = '$orderid' WHERE customerid = '$customerid'";
You were using single quotes instead of back tick (`) around table name and column.
Jul 8 '07 #2
mwasif
802 Recognized Expert Contributor
Also replace your update query line to this

[PHP]$result = mysql_query($sq l) or die ("Unable to Update Customer Information. Error: ".mysql_error() );[/PHP]

mysql_error() will return the sql error.
Jul 8 '07 #3

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

Similar topics

2
7155
by: Barbara | last post by:
Hi, I have an sql database that has the primary key set to three fields, but has not been set as unique(I didn't create the table). I have 1 record that has 2 duplicates and I am unable to delete the duplicate entries. If I try to delete any of the three records(they are identical) I get the message 'key column is insufficient or incorrect. Too many rows were affected by update'. I am trying to do this within Enterprise Mgr. Any...
4
3400
by: John Baker | last post by:
Hi: I have two tables, a setup table (TblSetup) and a purchase order table (tblPO). When i construct a query with ONLY the tblPO shown, and a type in parameter for the PO number, I an update the original tblPO. However, when I introduce the setup file into the query I cannot update the result. THis is true if I make a link to Setup or not. In fact, setup contains the client ID, which i wish to test against the client ID in the PO...
7
3691
by: travlintom | last post by:
Hi. I'm new to VB.net and am used to working with recordsets (much easier). I have a datagrid that, when the user double clicks on a row, I am giving them a chance to delete it. I thought this would be simple but it's taking me forever. I am getting an error when I try to delete the record. I can't figure out what I'm doing wrong. The error is "Object reference not set to an instance of an object". None of the incredibly overpriced books...
1
2431
by: Bruno BAGUETTE | last post by:
Hello, I'm trying to build a PL/PGSQL function that will be called by a trigger which will update a table named 'mview_contacts'. That table plays the role of a materialized view. The 'plpgsql' language is installed on that database (there are already several functions inside) but I don't understand why I can't store that function in the database.
17
3153
by: rdemyan via AccessMonster.com | last post by:
With A2003, I'm having trouble accessing files in a folder on another computer where back-end files, update files, etc are located. Here's the scenario: 1) Computer #1 - A2003 2) Computer #2 - Access 2000; folder with back-ends for both computers and 'Update' folder. I have a launcher program that launces my application (MyApp). The launcher program also checks for updates to MyApp located in 'Update' folder (on
0
1399
by: Terence | last post by:
Hi, I have a web user control which includes a gridview and a sqldatasource. It also has a property called TableName which is used to populate the gridview. However, i'm running into a problem where i can select and delete row but i cannot update a row. Here is the code in the usercontrol protected void Page_Load(object sender, EventArgs e)
1
6134
by: sheenaa | last post by:
Hello Members, I m creating my application forms in ASP.Net 2005 C# using the backend SQL Server 2005. What i have used on forms :: ? On my first form i have used some label,textboxs,dropdownlists,radiobutton and checkbox asp standard controls. On the click event of the command button the data gets stored into the database. I have created the stored procedures for the insert,update,delete. I have...
1
2412
by: Markw | last post by:
Hi folks I think I've got a variable problem but not 100% sure. Background: I took the CMS example from chapter 6 in "Build your Own Database Driven Website Using PHP&MySQL" and have attempted to modify it for use in my own database. It almost works for me LOL. contact.php returns my dive buddies first and last name and gives me the option to either Edit or Delete them. Currently the delete option is not active. When I choose to edit...
3
1909
by: Constantine AI | last post by:
Hi i am trying to DELETE a Record if the details do not exist within a table. Here is my code below; Dim strSQL As String Dim strSQL2 As String Dim Reply As String Dim db As Database Dim rst As Recordset Dim SeqItemNo As Integer DoCmd.SetWarnings False
0
9618
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
10260
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...
0
9906
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...
0
8933
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
7456
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
6712
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();...
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
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.