473,401 Members | 2,146 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,401 software developers and data experts.

Unable to update and delete

[PHP]
<?
session_start();

require("db.php");

mysql_connect(MACHINE, USER, '');
mysql_select_db(DBNAME);

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

if(isset($username)){

$customerid = $_POST['customerid'];
$customername = $_POST['customername'];
$customercontact = $_POST['customercontact'];
$orderid = $_POST['orderid'];

$sql = "SELECT * FROM customer";

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

$row = mysql_fetch_assoc($result);
extract($row);

}
?>

<html>
<head>
<title>Update Customer Details</title>
</head>
<body>
<form action="do_updatecustomer.php?action=do_updatecust omer&orderid=<?php echo $orderid; ?>" enctype="multipart/form-data" method='post'><br>
<link rel="stylesheet" type="text/css" href="fyp.css" />
<b></b><br><br>
<table border="0">

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

<tr><td>Customer Contact:</td>
<td><input type="text" name ="customercontact" value ="<?php echo $customercontact; ?>"></td></tr>

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

<tr><td><input 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(MACHINE, USER, '');
mysql_select_db(DBNAME);

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


$sql = "UPDATE 'customer' SET 'customername' = '$customername',
'customercontact' = '$customercontact','orderid' = '$orderid' WHERE 'customerid' = '$customerid'";

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


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


//<br><br>
//"<a href=cus_details.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 1728
mwasif
802 Expert 512MB
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 Expert 512MB
Also replace your update query line to this

[PHP]$result = mysql_query($sql) 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
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...
4
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...
7
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...
1
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...
17
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 -...
0
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...
1
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...
1
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...
3
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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...
0
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...
0
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,...

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.