Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

whats wrong with this? 1

Status
Not open for further replies.

jodiep

Technical User
Jul 23, 2003
6
0
0
IE
hi there:
the idea of the following code is : $q is a result set with products_id and quantity, and i want to update the table products with this values, simple enough? not!
the script run but doesnt changes anything i tryed everything ican think of. please let me know what am I doing wrong

While ($row=mysql_fetch_row($q))
{
$up_q=mysql_query("UPDATE products Set products.products_quantity = '$row[1]' AND products_last_modified = NOW() WHERE products_id = '$row[0]' ");
if (mysql_affected_rows()>0){
echo "Changed Product: $row[0] stock is now: $row[1] <br>";
}
 
As a quicker answer (though I highly recommend the excellent FAQs on this site), replace your AND with just a comma. You might also grab a mysql manual site and read up on the UPDATE syntax (I check it all the time, whenever there is a problem... sometimes my brain fills in things that ought not be in the query :)). Try this line:

Code:
$up_q = mysql_query("UPDATE products set products_quantity='".$row[1]."',products_last_modified=NOW() WHERE products_id = '".$row[0]."'");

Marc
 
marc: thanks a lot the AND was the problem i quote you "... sometimes my brain fills in things that ought not be in the query" well you know is the kind of thing you can read 100 times and not spot.
sleipnir214, I m sure this never happened to you ...

Cheers

j
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top