1

我有这个代码:

<?php
include 'config.php';
date_default_timezone_set('America/Los_Angeles');
$d = date('Y-m-d');
$m = date("m");
$day = date("d");
$t = date("His");
$ip = $_SERVER['REMOTE_ADDR'];
$c = file_get_contents('http://api.wipmania.com/'.$ip);

echo "<h2>ALL RESULTS TODAY:</h2><table>";
$_GET['c'] = $c;
$sc = $_GET['sc'];
if($c === "key"){
    if($sc === "t"){
        $result = "SELECT * FROM main WHERE date = '$d' ORDER BY time";
        while($row = mysqli_fetch_array($result))
  {echo "<tr><td>".$row['key'] . "</td><td> " . $row['country']."</td><td>".$row['ip']."</td></tr>";  }
        }

}

echo '</table>';
?>

我试过没有$con: mysqli_fetch_array($result),但它是一样的......

但是什么都没有出现...没有错误没有结果...请帮助...谢谢!

4

3 回答 3

1

您尚未连接到数据库或查询您的结果:

$conn = mysqli_connect($hostname,$username,$password,$dbname) or die(mysqli_error());
//...
$your_query = "SELECT * FROM main WHERE date = '$d' ORDER BY time";
$result = mysqli_query($conn, $your_query);
while ($row = mysqli_fetch_array($result)){
  //...
}
于 2013-08-30T18:48:01.157 回答
0

你忘了mysqli_query

替换这个

   $result = "SELECT * FROM main WHERE date = '$d' ORDER BY time";

经过

   $result =mysqli_query("SELECT * FROM main WHERE date = '$d' ORDER BY time");
于 2013-08-30T18:53:44.423 回答
0

您忘记执行查询。

$result = mysqli_query($con, "SELECT * FROM main WHERE date = '$d' ORDER BY time");
于 2013-08-30T18:48:24.860 回答