0

i'm new to back end work and this i'm just having a play round with it i have a database with some data in it and when i try and do a query on it, it just wont return anything, i tested to see if it was connected also using mysql_ping() and it returned 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;
*/

?>     
JkenGJ
  • 35
  • 6

0 Answers0