I
I
Ilya2015-12-05 01:59:36
PHP
Ilya, 2015-12-05 01:59:36

Changing an entry in a MySQl database in PHP?

Hello, tell me what's the catch, when you click on the link , it
<a href="./archive?id=4">опубликовать</a>
ignores the expression

if (isset($_GET['id']) && $_GET['id'] != '') {
  require_once './connect_db.php';
  $mysqli_table = 'journal_article';
  $sql = "UPDATE ".$mysqli_table." SET `status`= '1' WHERE `id` = '".$_GET['id']."'";
  $result = mysqli_query($db, $sql);
}

* typo fixed

Answer the question

In order to leave comments, you need to log in

3 answer(s)
O
OVK2015, 2015-12-05
@OVK2015

Try changing the if yourself:
if (isset($_GET['id']) && ($_GET['id'] != ''))

D
D', 2015-12-05
@Denormalization

There is an obvious error here:
You need this:
if (isset($_GET['id']) && $_GET['id'] != '') {

M
mihelsonkk, 2015-12-05
@mihelsonkk

$result = mysqli_query($db, $sql);
php.net/manual/en/mysqli.query.php
sql code should be in the first parameter. read the function's documentation before using it.
read about sql injection and filtering incoming data

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question