Hello, I ran into a problem with my PHP code, my code works for adding a new record to the database, but for editing a record it doesn't work, and the MySql statement looks fine to me but the UPDATE doesn't seem to work on the record for some reason. -
if($itemno == 0)
-
{
-
$buildsql = "INSERT INTO products (title, catid, list, price, taxable, shipping, intshipping, calculator, description) ";
-
$buildsql = $buildsql . "VALUES ('" . $title . "', '" . $catid . "', '" . $list . "', '" . $price . "', '" . $taxable . "', '" . $shipping . "', '" . $intshipping . "', '" . $calculator . "', '" . $description . "')";
-
mysql_query($buildsql);
-
$itemno = mysql_insert_id($con);
-
echo "<table border='1' width='400' align='center'><tr><td bgcolor='#C0C0C0' align='center'><b>Item Added</b></td></tr>
-
<tr><td><b>Added item number: </b>" . $itemno . "<br><br><form action='imgupload.php' method='get'><b>
-
<input type='hidden' value=" . $itemno . " name='itemno' /><p align='right'><input type='submit' value='Upload Images'>
-
</p></td></tr>";
-
}
-
else
-
//Edit item
-
{
-
$buildsql = "UPDATE products SET title='" . $title .
-
"' catid='" . $catid . "' list='" . $list .
-
"' price='" . $price . "' taxable='" . $taxable .
-
"' shipping='" . $shipping . "' intshipping='" . $intshipping .
-
"' calculator='" . $calculator . "' description='" . $description .
-
"' WHERE itemno='" . $itemno . "'";
-
echo "<b>" . $buildsql . "</b>";
-
mysql_query($buildsql);
-
}
-
What am I doing wrong? Thanks again for your help!
3 3168
ok.. you have a wrong Udate query expression .. should be "," after every field want to update.. -
-
this code should wrk to you
-
-
$sql = "UPDATE products SET title = '".$title."', catid = '".$catid."', list = '".$list."', ";
-
$sql .= "price = '".$price."', taxable = '".$taxable."', ";
-
$sql .= "shipping = '".$shipping."', ";
-
$sql .= "intshipping = '".$intshipping."', calculator = '".$calculator."', description = '".$description."' ";
-
$sql .= "WHERE itemno = '".$itemno."' ";
-
-
mysql_query($sql)or die("cant execute: $sql");
-
-
You're a life saver, thanks!
you are more then welcome ...
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Mark A Framness |
last post by:
Greetings,
I am working on a project and we need to write a conversion script to
initialize a new field on a table. The number of records on this table
is on the order of millions so routine...
|
by: Dave |
last post by:
I have 2 tables, one with names, and another with addresses, joined by their
CIVICID number (unique to the ADDRESSINFO table) in Oracle.
I need to update a field in the NAMEINFO table for a...
|
by: Lauren Quantrell |
last post by:
In VBA, I constructed the following to update all records in
tblmyTable with each records in tblmyTableTEMP having the same
UniqueID:
UPDATE
tblMyTable RIGHT JOIN tblMyTableTEMP ON...
|
by: pb648174 |
last post by:
I have a single update statement that updates the same column multiple
times in the same update statement. Basically i have a column that
looks like .1.2.3.4. which are id references that need to...
|
by: Mike Leahy |
last post by:
Hello all,
This question is related to updating tables - is there any way to calculate or
update the values in a column in a table to the values in a field produced by
a query result? An...
|
by: amitbadgi |
last post by:
HI i am getting the foll error while conv an asp application to
asp.net
Exception Details: System.Runtime.InteropServices.COMException: Syntax
error in UPDATE statement.
Source Error:
Line...
|
by: Grant McLean |
last post by:
Hi
First a simple question ...
I have a table "access_log" that has foreign keys "app_id" and
"app_user_id" that reference the "application_type" and "app_user"
tables. When I insert into...
|
by: FayeC |
last post by:
I really need help figuring this out.
i have a db with mostly text fields but 2.
The user_id field is an autonumber (key) and the user_newsletter is a
number (1 and 0) field meaning 1 yes the ...
|
by: Steve |
last post by:
ASP error number 13 - Type mismatch with SELECT...FOR UPDATE statement
I got ASP error number 13 when I use the SELECT...FOR UPDATE statement
as below.
However, if I use SELECT statement without...
|
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...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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...
| |