affordit Posted February 24, 2008 Share Posted February 24, 2008 Can someone tell me whats wrong with this update query? $i = 0; while ($info = mysql_fetch_array($result)) { $acctnum = createAcctNum(); // UPDATE THE ROW // $update = "UPDATE `test` SET `acct_num`= . $city . '-' . $acctnum . '-' . $info['id'] WHERE `id`=" . $info['id'] or die (mysql_error()); mysql_query($update); echo "updated" . $username; $i++; } Quote Link to comment Share on other sites More sharing options...
schilly Posted February 24, 2008 Share Posted February 24, 2008 Try this and see if you get an error <?php $update = "UPDATE `test` SET `acct_num`= $city-$acctnum-" . $info['id'] . " WHERE `id`=" . $info['id']; mysql_query($update) or die (mysql_error()); echo "updated" . $username; $i++; } ?> Quote Link to comment Share on other sites More sharing options...
affordit Posted February 24, 2008 Author Share Posted February 24, 2008 Unknown column 'KLA' in 'field list' (This is the city var) Quote Link to comment Share on other sites More sharing options...
schilly Posted February 24, 2008 Share Posted February 24, 2008 Echo the $update sting and post it. I'm thinking you need quotes around the account_num value. $update = "UPDATE `test` SET `acct_num`= '$city-$acctnum-" . $info['id'] . "' WHERE `id`=" . $info['id']; Quote Link to comment Share on other sites More sharing options...
affordit Posted February 24, 2008 Author Share Posted February 24, 2008 Just a blank page Quote Link to comment Share on other sites More sharing options...
affordit Posted February 25, 2008 Author Share Posted February 25, 2008 Just a blank page Quote Link to comment Share on other sites More sharing options...
Bauer418 Posted February 25, 2008 Share Posted February 25, 2008 <?php $update = "UPDATE `test` SET `acct_num`='" . mysql_real_escape_string($city . '-' . $acctnum . '-' . $info['id']) . "' WHERE `id`='" . mysql_real_escape_string($info['id']) . "'"; mysql_query($update) or die (mysql_error()); echo "updated" . $username; $i++; } ?> I may have gone overboard with mysql_real_escape_string, but you should always be cleaning your variables before using them in a query. Quote Link to comment Share on other sites More sharing options...
affordit Posted February 25, 2008 Author Share Posted February 25, 2008 Thanks work great 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.