refiking Posted February 19, 2008 Share Posted February 19, 2008 I have 16 fields that I need to update and I'd like to do it with one query as opposed to 16 separate ones. When I tried this, it didn't work: $change = "UPDATE gatable SET (r1g1,r1g2,r1g3,r1g4,r1g5,r1g6,r1g7,r1g8,r1g9,r1g10,r1g11,r1g12,r1g13,r1g14,r1g15,r1g16) VALUES ('$r1g1','$r1g2','$r1g3','$r1g4','$r1g5','$r1g6','$r1g7','$r1g8','$r1g9','$r1g10','$r1g11','$r1g12','$r1g13','$r1g14','$r1g15','$r1g16')"; Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted February 19, 2008 Share Posted February 19, 2008 Did you actually try to execute the query with mysql_query()? Try this: <?php $change = "UPDATE gatable SET (r1g1,r1g2,r1g3,r1g4,r1g5,r1g6,r1g7,r1g8,r1g9,r1g10,r1g11,r1g12,r1g13,r1g14,r1g15,r1g16) VALUES ('$r1g1','$r1g2','$r1g3','$r1g4','$r1g5','$r1g6','$r1g7','$r1g8','$r1g9','$r1g10','$r1g11','$r1g12','$r1g13','$r1g14','$r1g15','$r1g16')"; $result = mysql_query($change)or die(mysql_error() . "<p>With Query $change"); ?> Copy and paste the error if you get one. Quote Link to comment Share on other sites More sharing options...
Chris92 Posted February 19, 2008 Share Posted February 19, 2008 No, the UPDATE works different to INSERT: $change = "UPDATE `gatable` SET `r1g1` = '$r1g1', `r1g2` = '$r1g2', `r1g3` = '$r1g3'"; and so on. Quote Link to comment Share on other sites More sharing options...
refiking Posted February 19, 2008 Author Share Posted February 19, 2008 Ahh ok. Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.