PHP从MySQL获取数据不起作用

时间:2018-07-20 20:59:20

标签: php mysql

<?php

$servername = "someserver";
$username = "termodom_TMAL";
$password = "somepassword";
$dbname = "termodom_TDMajstor";

$conn = mysqli_connect($servername, $username, $password, $dbname);

if(!$conn)
{
    die("connection failed: " . mysqli_connection_error());
}

$sql = "SELECT KORISNIKID, IME, SIFRA FROM KORISNIK";
$result = mysqli_query($conn, $sql);

if(mysql_num_rows($result) > 0)
{
    while($row = mysqli_fetch_assoc($result))
    {
        echo "id: " . $row["KORISNIKID"] . "<br>";
    }
}
else
{
    echo "0 results";
}
?>

这是我所拥有的代码,由于某种原因它返回0 results消息,但在我的表中却有行。

phpMyAdmin中,数据库名称为termodom_TDMajstor,它的表KORISNIK内有一行。

我在做什么错了?

0 个答案:

没有答案