Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi, I'm having a bit of trouble editing the prices in a price list for a site I've created...
I've created the form and table for the actual prices to be typed in and sent to the processing page but I'm struggling to get them to actually work.
There's another page on the site where details of cars for sale can be changed and the query is simple enough since I'm editing the details for just one car. The problem with the pricelist is that I'm editing a number of entries in the table and I keep getting errors (Invalid query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE p.id = '0'' at line 5) whenever I try to submit it. Any ideas how to get this working? The code in the process form is below...
foreach($price as $id => $price)
{
$sql = "UPDATE
pricelist p
SET
p.price = '$price',
WHERE
p.id = '$id'";
$result = mysql_query($sql) or die("Invalid query: ".mysql_error());
}

It always helps to see the FULL query when trying to debug. I will usually echo quries to the page during the development phase. Plus you could change your "on die" function as follows:
$result = mysql_query($sql) or die("The query:
".$sql."
Caused the following error:
".mysql_error());If the full query is valid you will want to verify that the table and field names are exactlythe same as they are in the database. Plus, I am assuming that price and id are numeric fields int he database. In that case you can remove the single quotes from around the values. I don't think that will cause an error, but it might depending upon your version of MySQL.
Michael J

![]() |
RDP embed
|
Ultimate Slideshow - Big ...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |