jaxdevil Posted November 2, 2007 Share Posted November 2, 2007 I am trying to insert data into multiple fields in multiple rows, I have it working where I can submit to multiple entries, but when i try to update more than one field I get an error. The first code below works, but only lets me update one section of each row, the second code is what I am trying to use to update several columns in those fields.... <?php // connect to the database and select the correct database mysql_connect(localhost,xxx_xxx,xxxxxx); mysql_select_db(auction_asset) or die("Unable to select database"); $query = "UPDATE checkout SET ref='$authxyz' WHERE bidnum=$custidxyz AND paid='no'"; mysql_query($query) or die ("Error in query: $query"); print "data<br /><br /><em>Updated!</em><br /><br />"; mysql_close(); ?> <?php // connect to the database and select the correct database mysql_connect(localhost,xxx_xxx,xxxxxx); mysql_select_db(auction_asset) or die("Unable to select database"); $query = "UPDATE checkout SET ref='$authxyz' AND SET paid='yes' AND SET type='cc' WHERE bidnum=$custidxyz AND paid='no'"; mysql_query($query) or die ("Error in query: $query"); print "data<br /><br /><em>Updated!</em><br /><br />"; mysql_close(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/75752-solved-update-more-than-one-field/ Share on other sites More sharing options...
~n[EO]n~ Posted November 2, 2007 Share Posted November 2, 2007 I think you must keep the UPDATE query inside a while loop, just try once... Quote Link to comment https://forums.phpfreaks.com/topic/75752-solved-update-more-than-one-field/#findComment-383373 Share on other sites More sharing options...
jaxdevil Posted November 2, 2007 Author Share Posted November 2, 2007 Thanks. I figured it out... <?php // connect to the database and select the correct database mysql_connect(localhost,xxx_xxx,xxxxxx); mysql_select_db(auction_asset) or die("Unable to select database"); $query = "UPDATE checkout SET paid='yes', ref=$authxyz, type='cc' WHERE paid='no' AND bidnum=$custidxyz"; mysql_query($query) or die ("Error in query: $query"); print "data<br /><br /><em>Updated!</em><br /><br />"; mysql_close(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/75752-solved-update-more-than-one-field/#findComment-383375 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.