Answer the question
In order to leave comments, you need to log in
Why does sql query only update numeric values?
The SQL query updates the fields in the database only if the input value is a numeric format, in the case of text, nothing happens at all.
---------------
PHP script code:
require_once('../blocks/connection_db.php');
$article = $_GET['article'];
$name = $_GET['name'];
$description = $_GET['description'];
$parameters = $_GET['parameters'];
$manufacturer = $_GET['manufacturer'];
$cost = $_GET['cost'];
$request = "UPDATE products SET name = '$name', description = '$description', parameters = '$parameters', manufacturer = '$manufacturer', cost = '$cost' WHERE article = $article";
$connection_db -> query($request);
header('Location:/within.php');
Answer the question
In order to leave comments, you need to log in
Because collecting sql in this way (by setting strings and concatenating) is a very bad idea. Use parameterized queries. Even in. Php can and should do it.
Because the $article variable is not wrapped in parentheses:
$request = "UPDATE products SET name = '$name', description = '$description', parameters = '$parameters', manufacturer = '$manufacturer', cost = '$cost' WHERE article = $article";
$request = "UPDATE products SET name = '$name', description = '$description', parameters = '$parameters', manufacturer = '$manufacturer', cost = '$cost' WHERE article = '$article'";
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question