I’m studying php and mysql from a book. Everything has worked so far! Now we have this function totaljokesfunction.inc.php:
<?php
// login to mysql
include_once $_SERVER['DOCUMENT_ROOT'] . '/includes/db.inc.php';
function totalJokes()
{
try
{
$result = $GLOBALS['pdo']->query('SELECT COUNT(*) FROM jokes');
}
catch (PDOException $e)
{
$error = 'Database error counting jokes!';
include $_SERVER['DOCUMENT_ROOT'] . '/includes/error.html.php';
exit();
}
$row = $result->fetch();
return $row[0];
}
?>
I have an index.php and firstjoke.html.php and totaljokesfunction.inc.php
I want to output the result of totaljokesfunction.inc.php in firstjoke.html.php but I can’t.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Jokes</title>
</head>
<body>
<p>
<h2>The first joke is:</h2>
<?php $output = $_SERVER['DOCUMENT_ROOT'] . '/includes/totaljokesfunction.inc.php';
echo $output; ?>
</p>
</body>
</html>
All I get is:
The first joke is:
/var/www/html/includes/totaljokesfunction.inc.php
How do I output the result of totaljokesfunction.inc.php please??