Jump to content

Not Updating


affordit

Recommended Posts

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++;

}

Link to comment
https://forums.phpfreaks.com/topic/92767-not-updating/
Share on other sites

<?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.

Link to comment
https://forums.phpfreaks.com/topic/92767-not-updating/#findComment-475466
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.