I want to make query to mysql, but when i execute it at end of the page i have needless text. How can i delete it?
this is the code:
try {
//create PDO connection
$db = new PDO("mysql:host=".DBHOST.";port=3306;dbname=".DBNAME, DBUSER, DBPASS);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
//show error
echo '<p class="bg-danger">'.$e->getMessage().'</p>';
exit;
}
$stmt = $db->query('SELECT * FROM temperature');
while ( $row = $stmt->fetch(PDO::FETCH_ASSOC)) {
echo $row['timestamp'] . "\t" . $row['humidity'] . "\n";
}
?>
This is the output:
2015-06-16 13:07:47 89 2015-06-16 13:08:46 0 2015-06-16 13:08:56 86 2015-06-16 13:09:06 86 2015-06-16 13:09:16 86 2015-06-16 13:09:27 86 query('SELECT * FROM
temperature'); while ( $row = $stmt->fetch(PDO::FETCH_ASSOC)) { echo $row['timestamp'] . "\t" . $row['humidity'] . "\n"; } } } */?>
.phpextension? Is your computer setup as a webserver with both PHP/MySQL installed? Your question is unclear. another thing... you do have an opening<?phptag, right? Gawd, I hate guessing, unless it's "charades".