T
T
tost582015-09-27 21:07:02
PHP
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';
$id=$_REQUEST['id'];
$text=trim($_REQUEST['text']);
$age=trim($_REQUEST['age']);
$mail=trim($_REQUEST['mail']);
$gender=trim($_REQUEST['gender']);
$smoking=trim($_REQUEST['smoking']);

$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)
A
Alexander Melekhovets, 2015-09-28
@tost58

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

I
IceJOKER, 2015-09-27
@IceJOKER

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

D
danforth, 2015-09-28
@danforth

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