我刚接触到后端工作,而我只是玩了一个游戏,我有一个包含一些数据的数据库,当我尝试对它进行查询时,它就不会返回任何东西,我测试了它是否也使用mysql_ping()连接并返回1.
<?php
/*Database*/
$host = '127.0.0.1';
$username = 'root';
$pw = '';
$conDB = new PDO('mysql:host = $host;dbname = $username', $username,$pw) or die("cant connect");
if($conDB){
echo 'connection made';
}
else{
echo 'error';
}
$clientIP = $_SERVER['REMOTE_ADDR'];
$statement = $conDB->prepare("
SELECT * FROM `ip log`
");
$statement->execute();
foreach($statement as $test){
echo $test['Address'];
}
/*
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
echo $res;
*/
?>