php call to undefined html_begin

php    call to undefined html_begin

do I have to enable
in the php.ini file
shopjdAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Roger BaklundCommented:
It means you are trying to call a function which is not defined. It can not be enabled in php.ini, you simply have to define the function:
function html_begin() {
  # function code here
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ray PaseurCommented:
This might occur because you have an include statement that failed.  If it is written as @include() the failure will not be apparent because the error message is suppressed by the @ sign.

Often I have seen this sort of thing when the @include() statement was expected to bring in a PHP file with a group of local functions.  The PHP file was not found (for whatever reason).

You might want to scan the code for the @ sign and remove it from the fron of any functions.  Also, put error_reporting(E_ALL); at the top of your scripts.  If you do those two things, you will be able to see any errors and assumptions that PHP is making on your behalf.

HTH, ~Ray
0
shopjdAuthor Commented:
error:
call to undefined function html_begin()
at dump_members.php line 5

what should I declare in sampdb_pdo.php
for html_begin  and html_end  to make the code work
dump_members.php
 
<?php
# USHL home page - version 4
require_once "sampdb_pdo.php";
$title = "U.S. Historical League";
html_begin ($title, $title);
?>
<p>Welcome to the U.S. Historical League Web Site.</p>
<?php
try
{
$dbh = sampdb_connect ();
$sth = $dbh->query ("SELECT COUNT(*) FROM member");
$count = $sth->fetchColumn (0);
print ("<p>The League currently has $count members.</p>");
$dbh = NULL; # close connection
}
catch (PDOException $e) { } # empty handler (catch but ignore errors)
?>
<p>
You can view the directory of members <a href="dump_members.php">here</a>.
</p>
<?php
html_end ();
?>
 
 
sampdb_pdo.php
 
<?php
 #sampdb_pdo.php-commmon functions for sample pdo-based scripts function that uses username and password to connect to mysql server to use the sampdb database.  It also enables exceptions for errors that occur for subsequent pdo calls return value is the database handle produced by the new pdo()
 function sampdb_connect ()
 {
  $dbh = new PDO("mysql:host=localhost;dbname=april", "root","");
  $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  return($dbh);
 }
?>

Open in new window

0
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

Ray PaseurCommented:
Where did you get this code?  Was it purchased?  If so, you might want to contact the vendor.
0
Roger BaklundCommented:
>> what should I declare in sampdb_pdo.php

I answered that above: you must define the functions before you use them.

This seems to be from a book by Paul DuBois. These functions can be found online, here:

http://mysql-dox.net/Sams-MySQL-The.Definitive.Gu/0672326736/ch08lev1sec1.html
function html_begin ($title, $header)
{
    print ("<html>\n");
    print ("<head>\n");
    if ($title != "")
        print ("<title>$title</title>\n");
    print ("</head>\n");
    print ("<body bgcolor=\"white\">\n");
    if ($header != "")
        print ("<h2>$header</h2>\n");
}
function html_end ()
{
    print ("</body></html>\n");
}

Open in new window

0
Ray PaseurCommented:
@cxr: Amazingly Great Catch!  I would never have thought to look up the Historical League!  Ha!, ~Ray
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.