1

Whenver i try to update my columms in a selected row from PHP, it passed through without error, but it doesn't update in the database.

$query = "UPDATE news SET title = '$title', 
                  cover = '$cover', desc = '$newz', category = '$category' 
        WHERE id = $newz_select_id";
4

1 回答 1

4

desc is a reserved keyword in MySQL. Escape it with backtick ( ` ) instead.

$query = "UPDATE news SET title = '$title', 
              cover = '$cover', `desc` = '$newz', category = '$category' 
    WHERE id = $newz_select_id";

by the way, your code is very susceptible to sql injection. in order to avoid it, please study and use PHP PDO or PHP mySQLi Extensions.

See this Link: Best way to prevent SQL Injection

于 2012-09-23T14:24:26.283 回答