-11

I am working on a school project, but my code only returns ann HTTP 500 Error while running it. PHP and MySQL are correctly installed and work. I have tested this by using a INSERT command.

My code:

<?php


// Some inputvalues (those are correct)
$user = "";
$pass = "";
$host = "";
$db = "";

$conn = mysqli_connect($host, $user, $pass, $db)
    or die("Het is niet gelukt om te verbinden met de database!");


// Vaststellen wat je wil weten
$grab = $_GET['grab'];

$query = "SELECT * FROM informaticaproject WHERE id=1";
$result = mysqli_query($conn, $query)
    or die("Geen gegevens opgehaald!");

echo $result;

while ($row = mysqli_fetch_assoc($result)) {
    $anwer = $row["'" . $grab . "'"];
}

echo $answer;


mysqli_close($conn);

Can somebody help me please?

DeBruss
  • 9
  • 1
  • 4
    `$anwer = $row[$grab];` Try this. Should work. It is not coding issue, `echo $answer;` assigning to `anwer` and checking `answer`. Learn to have patience. – Rahul Mar 18 '19 at 10:06
  • @RahulMeshram thank you, but this doesn't work. The problem is that I do not get any results. – DeBruss Mar 18 '19 at 10:08
  • Debug first! Go line by line. `print_r($result)` or else trying penetrating `echo 1;` in between. enable [error reporting](https://stackoverflow.com/questions/5438060/showing-all-errors-and-warnings). Start by yourself. You can do it. – Rahul Mar 18 '19 at 10:10

1 Answers1

0
//Try This

<?php


// Some inputvalues (those are correct)
$user = "";
$pass = "";
$host = "";
$db = "";

$conn = mysqli_connect($host, $user, $pass, $db)
    or die("Het is niet gelukt om te verbinden met de database!");


// Vaststellen wat je wil weten
$grab = $_GET['grab'];

$query = "SELECT * FROM informaticaproject WHERE id=1";
$result = mysqli_query($conn, $query)
    or die("Geen gegevens opgehaald!");

echo $result;

while ($row = mysqli_fetch_assoc($result)) {
    $anwer = $row["'" . $grab . "'"];
}

echo $anwer;


mysqli_close($conn);