Jump to content

Recommended Posts

Hi, I'm getting this error
Fatal error: Call to undefined function headerInfo() in /web/html/mediaservicesunlimited.com/bixler/template.php on line 18
 

functions.php is uploaded and headerInfo is spelled the same in the functions and the template file so I can't figure out what 's wrong.  if I can get some help that would be great!  Thanks

 

template.php

<php
require_once('functions.php');
?>  
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<meta name="keywords" content="">
<meta name="description" content="">
<link rel = "stylesheet" href = "Bixler.css">  
<style type="text/css">

</style>
</head>
<body>
<?php
	headerInfo(); 
?>   

<article>

</article>
<aside>

</aside>

</body>
</html>

functions.php

function headerInfo() {
echo "<header>"; 
echo "<nav>"; 
	echo "<ul id=\"drop-nav>\">"; 
		echo "<li><a href=\"#\">Home /a></li>"; 
		echo "<li><a href=\"#\">About Us</a>"; 
    echo "<ul>"; 
	echo "<ul>"; 
		echo "<li><a href=\"#\">About Bixler</a></li>"; 
		echo "<li><a href=\"#\">Agents</a></li>"; 
		echo "<li><a href=\"#\">Locations</a></li>"; 
		echo "<li><a href=\"#\">Testimonies</a></li>"; 
		echo "<li><a href=\"#\">News & Resources </a></li>"; 
    echo "</ul>"; 
	echo "</li>"; 
		echo "<li><a href=\"#\">  Services</a>"; 
    echo "<ul>"; 
		echo "<li><a href=\"#\">Personal</a></li>"; 
		echo "<li><a href=\"#\">Life</a></li>";
		echo "<li><a href=\"#\">Commercial</a></li>"; 
		echo "<li><a href=\"#\">Health</a></li>";
		echo "<li><a href=\"#\">Senior Benefits</a></li>"; 
		echo "<li><a href=\"#\">Farm</a></li>"; 
		echo "</ul>"; 
  echo "</li>"; 
	echo "<li><a href=\"#\">Get A Quote</a></li>"; 
		echo "<li><a href=\"#\">Contact</a>"; 
    echo "<ul>"; 
		echo "<li><a href=\"#>\">General Inquiries</a></li>"; 
		echo "<li><a href=\"#\">Pay My Bill</a></li>"; 
    echo "</ul>"; 
    echo "</li>"; 
	echo "</ul>"; 
echo "</nav>"; 
echo "<figure id=\"logo\">"; 
   		echo "<img src=\"assets/bixlerlogo.png\" width=\"304\" height=\"88\" alt=\"logo\"/>"; 
echo "</figure>"; 
    </figure>
echo "<h3>Service Beyond The Contract </h3>"; 
echo "</header>"; 
}

/*end of headerInfo function */

/*start of footerInfo function */
function footerInfo() {
echo "<footer>"; 
	echo "<div id=\"contactInfo">"; 
    	echo "Bixler Insurance <br/>"; 
	    echo "1043 South 13th St. <br />"; 
	    echo "Decatur, IN 46733<br />"; 
, 		echo "Phone: (260)-724-3438"; 
    echo "</div>"; 
    echo "<div id="eocialMedia">"; 
		echo "social media icons"; 
    echo "</div>"; 
    echo "<div id="servicesList">"; 
    	echo "list of services"; 
    echo "</div>"; 
echo "</footer>"; 
}

/*end of footerInfo function */

Link to comment
https://forums.phpfreaks.com/topic/301173-call-to-undefine-function/
Share on other sites

Where is functions.php located?

 

if this is the path:

/web/html/mediaservicesunlimited.com/bixler/functions.php

 

Then do:

require_once('./functions.php');

 

If this is the path:

/web/html/mediaservicesunlimited.com/functions.php

 

Then do:

require_once('../functions.php');

Edited by benanamen

I do believe that if the file to be included is in the same folder as the calling script no path is needed, so the current line of code is correct. If however it is one folder up, then benanamen is giving the correct alteration.

 

Ps - While I love the way you use the function to encapsulate a whole bunch of html, the method of outputting could be so much easier if you use the heredocs feature. Here is the link to the php manual:

 

http://php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc

I love the way you use the function to encapsulate a whole bunch of html,

 

LOL! I didnt even look at the code in the function. OP, a simple include of clean html is a much better option than a function with all that ridiculous Php echoing Html. If your still going to do it with a function, escape the Php of the function and do straight Html.

 

I aso suggest you start using Html5

function footerInfo() {
?>
<footer>
    <div id="contactInfo">
        Bixler Insurance <br/>
        1043 South 13th St. <br />
        Decatur, IN 46733<br />
        Phone: (260)-724-3438
    </div>
    <div id="eocialMedia">
        social media icons
    </div>
    <div id="servicesList">
        list of services
    </div>
</footer>
<?php
}
Edited by benanamen

I have been working with it and, first I did put the opening and closing tags in the functions file.  I'm sorry, that was my error.  But it 's like it 's not seeing the function file.  The file is http://www.mediaservicesunlimited.com//bixler/functions.php which is the same directory as the template.php so the require statement should be

require_once('functions.php');

right? 

What exactly do you not understand? You need to fix the opening tag in your template.php, and you need to add PHP tags to your functions.php. If you do that, the problem will go away. If you don't, it will persist. Pretty simple.

 

Besides that, you might want to rethink your way of developing. Grab a proper IDE which highlights your code and points out “stupid mistakes” like broken PHP tags. Also install a local webserver instead of testing your stuff on the Internet. If your public website displays a bunch of PHP errors and lets anybody browse through unfinished customer projects, that's not exactly professional. Test code also tends to have a lot of bugs, which can become a serious threat for your production server.

Edited by Jacques1

Look at the opening php tag for the require_once() in template.php. Notice anything missing?

 

Holy crap a Pika sighting.  Must be because the Stars evened the series yesterday. I thought they were toast after that tire fire of a first period, but they hung around.

I have been working with it and, first I did put the opening and closing tags in the functions file.  I'm sorry, that was my error.  But it 's like it 's not seeing the function file.  The file is http://www.mediaservicesunlimited.com//bixler/functions.php which is the same directory as the template.php so the require statement should be

require_once('functions.php');

right? 

 

 

Sometimes you miss the forest for the trees.  See Pika's comment.

 

This will start a php block:

 

 

<?php

 

This won't

 

 

<php

Holy crap a Pika sighting.  Must be because the Stars evened the series yesterday. I thought they were toast after that tire fire of a first period, but they hung around.

 

Hahaha. Yeah, I'm around again. Probably not nearly as much as I used to be, but who knows? My poor Stars didn't do so well today . . .

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.