N
N
nagge1012018-02-12 17:16:18
PHP
nagge101, 2018-02-12 17:16:18

SQL query $_GET not working, why?

The situation is this. I'm doing some kind of Blog (according to the Howdy lesson). In the video tutorial, he creates the articles.php page, and on the main page he gives the links the following address href="name/articles.php?id=number", and in the articles.php itself he writes the request

$name = mysqli_query($connect, 'SELECT * FROM `articles` WHERE `id` = ' . (int) $_GET['id']);
// $connect переменная соединения с базой.

After the click, I have a link that looks correct, but the 404 page ...
accordingly, there are some problems, but everything works for him (howdy).

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
nagge101, 2018-02-12
@nagge101

I solved the problem by simply removing the slash before articles from href="/articles.php..."

P
Padre, 2018-02-12
@yii16

Watch Howdy, don't read books...

$id = intval($_GET['id']);
var_dump($id);
$name = mysqli_query($connect, "SELECT * FROM `articles` WHERE `id` = '".$id."'");
var_dump($name);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question