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 trialkamal vignesh
157 Pointsphp website is not working
i have created 3 basic webpages in notepd also the database. 1. connection.php for connecting to database <?php try {
$db = new PDO("mysql:host=localhost;dbname=project;port=3306","root","");
} catch(Exception $e) { echo $e->getMessage(); exit; } ?> 2. function.php to fetch the result from the database
<?php function get_student_list(){ include 'connection.php';
try { return $db->query('Select * FROM 'students'); } catch (Exception $e) { echo "error" . $e->getMessage() . "</br>"; } }
3. student.php to display the result <?php foreach (get_student_list() as $item) { include 'function.php'; echo "<li>" . $item['name'] . "</li>"; } ?> I have also created a database in the xampp for the student table which has a column "name". when i run my localhost it showed me an error like
Fatal error: Uncaught Error: Call to undefined function get_student_list() in C:\xampp\htdocs\student.php:2 Stack trace: #0 {main} thrown in C:\xampp\htdocs\student.php on line 2 can someone help me with this