Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Pontus Bolmér
Pontus Bolmér
12,471 Points

No output from my database server!

Hi! Im trying to get a simple text from my column(messages) from my tabel (mytabel) I know i have spelled the name wrong.

This is my code The problem is, i get no output from it!

What am i doing so wrong?

<?php echo "<br>"; DEFINE('DB_USERNAME', 'root'); DEFINE('DB_PASSWORD', 'root'); DEFINE('DB_HOST', 'localhost'); DEFINE('DB_DATABASE', 'performance_schema');

$mysqli = new mysqli(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_DATABASE);

if (mysqli_connect_error()) { die('Connect Error ('.mysqli_connect_errno().') '.mysqli_connect_error()); }

echo 'Connected successfully.';

$mysqli->close(); ?>

<?php echo "<br>"; echo "Hello my dear friend!"; $sth = $db->prepare("SELECT messages FROM mytabel"); print_r($sth); exit; $sth->execute(); $result = $sth->fetchAll(); print_r($result); ?>