tost582015-09-27 21:07:02
tost58, 2015-09-27 21:07:02

After editing a record on the web page, all records in the database are updated?

I select an entry on the web page, I want to update only it, and all entries in the database are updated and replaced with this particular entry. Why is that and how to fix it?

require 'connect.php';

$update_sql = "UPDATE tabl1 SET text='$text', age='$age', mail='$mail', gender='$gender' , smoking='$smoking' WHERE id='$id'";
mysql_query($update_sql) or die("Ошибка вставки" . mysql_error());
echo '<p>Запись успешно обновлена!</p>';

Answer the question

In order to leave comments, you need to log in

3 answer(s)
Alexander Melekhovets, 2015-09-28

I'm embarrassed to ask, do you have different records in your table that have different values ​​for the id field?

IceJOKER, 2015-09-27

before mysql_query()paste die($update_sql);and check the code.
hopefully somewhere in there..... you are filtering $_REQUEST otherwise you will be in for a big surprise... someday, from someone..
ps use mysqli/pdo

danforth, 2015-09-28

Maybe this file is connected in the body of some cycle?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question