PHP MySQL查询未返回结果

时间:2019-03-18 10:05:38

标签: php mysql

我正在做一个学校项目,但是我的代码在运行时仅返回HTTP 500错误。 PHP和MySQL已正确安装并正常工作。我已经通过使用INSERT命令进行了测试。

我的代码:

<div class="wrapper">
  <article>hero</article>
  <header>header</header>
  <main>main</main>
  <aside>aside</aside>
  <footer>footer</footer>
</div>

有人可以帮我吗?

1 个答案:

答案 0 :(得分: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);