This request does not work. In phpmyadmin , the request itself gives the result, the table is updated, but when I run the php-скрипт does not want to work. Although there are no mistakes. I think this one is due to the brackets. Or what?

  $id = $_GET['id']; $title = strip_tags(trim($_POST['title'])); $text = strip_tags(trim($_POST['text'])); $author = strip_tags(trim($_POST['author'])); mysql_query(" UPDATE users SET title=$title, text='$text', author='$author' WHERE id='$id' "); 

    1 answer 1

    Error here title=$title, no quotes.
    And so not very well write, use PDO and then you can do such things,

     // Подключение $link = mysql_connect('localhost', 'mysql_user', 'mysql_password'); if (!$link) { die('Ошибка соединения: ' . mysql_error()); } $id = $_GET['id']; $strip_tags(trim($_POST['title'])); $strip_tags(trim($_POST['text'])); $author = strip_tags(trim($_POST['author'])); $sql = "UPDATE users SET title='$title', text='$text', author='$author' WHERE id='$id'"; $result = mysql_query($sql); if (!$result) { die('Неверный запрос: ' . mysql_error()); } // Обновилось printf("Обновилось записей: %d\n", mysql_affected_rows()); 
    • Seravno does not work ... - user242433
    • @Cactus do as here mysql-query mysql_error() to view errors - Farkhod Daniyarov
    • There are no errors .. I do not even know what to do - user242433
    • @Cactus is not literal, change the description, enter all the code, so where is the connection and correct your listing like this: $sql = "UPDATE users SET title='$title', text='$text', author='$author' WHERE id='$id'" $result = mysql_query($sql); if (!$result) { die('Неверный запрос: ' . mysql_error()); } $sql = "UPDATE users SET title='$title', text='$text', author='$author' WHERE id='$id'" $result = mysql_query($sql); if (!$result) { die('Неверный запрос: ' . mysql_error()); } $sql = "UPDATE users SET title='$title', text='$text', author='$author' WHERE id='$id'" $result = mysql_query($sql); if (!$result) { die('Неверный запрос: ' . mysql_error()); } - Farkhod Daniyarov
    • @Cactus look, something like that should be - Farkhod Daniyarov