That works, it does not work, I do not understand what the problem is. look at the code. recently stopped updating records.

if (isset($_GET['red_id'])) { //Проверяем, передана ли переменная на редактирования if (isset($_POST['name'])) { //Если новое имя предано, то обновляем и имя и цену $sql = mysql_query('UPDATE `mtu4` SET ' .'`name` = "'.$_POST['name'].'",' .'`regis` = '.$_POST['regis'].',' .'`relat` = '.$_POST['relat'].',' .'`birth` = '.$_POST['birth'].',' .'`uch` = '.$_POST['uch'].',' .'`street` = '.$_POST['street'].',' .'`home` = '.$_POST['home'].',' .'`kvart` = '.$_POST['kvart'].',' .'`pasp` = '.$_POST['pasp'].',' .'`bio` = '.$_POST['bio'].',' .'`jer` = '.$_POST['jer'].',' .'`soz` = '.$_POST['soz'].',' .'`work` = '.$_POST['work'].',' .'`phone` = '.$_POST['phone'].' ' .'WHERE `id` = '.$_GET['red_id']); } if ($sql) { echo ""; } else { echo "<p>Произошла ошибка 1</p>"; } } 
  • one
    Maybe you have long been hacked? With this substitution of variables received from the outside directly into the query, SQL injection is done in a minute. go to PDO or mysqli and use the bind variables. php.net/manual/ru/pdostatement.bindparam.php - Mike

1 answer 1

A very courageous approach to making a request, you need to trust your users very much. Perhaps the problem is that strings are not enclosed in single quotes. Try this:

  $sql = mysql_query("UPDATE `mtu4` SET `name` = '".$_POST['name']."', `regis` = '".$_POST['regis']."', `relat` = '".$_POST['relat']."', `birth` = '".$_POST['birth']."', `uch` = '".$_POST['uch']."', `street` = '".$_POST['street']."', `home` = '".$_POST['home']."', `kvart` = '".$_POST['kvart']."', `pasp` = '".$_POST['pasp']."', `bio` = '".$_POST['bio']".', `jer` = '".$_POST['jer']."', `soz` = '".$_POST['soz']."', `work` = '".$_POST['work']."', `phone` = '".$_POST['phone']."' WHERE `id` = ".$_GET['red_id']);