mindapolis Posted May 6, 2016 Share Posted May 6, 2016 Hi, I'm getting this errorFatal 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 */ Quote Link to comment https://forums.phpfreaks.com/topic/301173-call-to-undefine-function/ Share on other sites More sharing options...
benanamen Posted May 6, 2016 Share Posted May 6, 2016 (edited) 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 May 6, 2016 by benanamen Quote Link to comment https://forums.phpfreaks.com/topic/301173-call-to-undefine-function/#findComment-1532910 Share on other sites More sharing options...
ginerjm Posted May 6, 2016 Share Posted May 6, 2016 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 Quote Link to comment https://forums.phpfreaks.com/topic/301173-call-to-undefine-function/#findComment-1532911 Share on other sites More sharing options...
Pikachu2000 Posted May 6, 2016 Share Posted May 6, 2016 (edited) Look at the opening php tag for the require_once() in template.php. Notice anything missing? Edited May 6, 2016 by Pikachu2000 1 Quote Link to comment https://forums.phpfreaks.com/topic/301173-call-to-undefine-function/#findComment-1532912 Share on other sites More sharing options...
Jacques1 Posted May 6, 2016 Share Posted May 6, 2016 (edited) Your functions.php also lacks PHP tags, so the file is treated as HTML. See here: http://www.mediaservicesunlimited.com/bixler/functions.php Edited May 6, 2016 by Jacques1 Quote Link to comment https://forums.phpfreaks.com/topic/301173-call-to-undefine-function/#findComment-1532913 Share on other sites More sharing options...
benanamen Posted May 6, 2016 Share Posted May 6, 2016 (edited) 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 May 6, 2016 by benanamen Quote Link to comment https://forums.phpfreaks.com/topic/301173-call-to-undefine-function/#findComment-1532916 Share on other sites More sharing options...
mindapolis Posted May 7, 2016 Author Share Posted May 7, 2016 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? Quote Link to comment https://forums.phpfreaks.com/topic/301173-call-to-undefine-function/#findComment-1532923 Share on other sites More sharing options...
Jacques1 Posted May 7, 2016 Share Posted May 7, 2016 (edited) 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 May 7, 2016 by Jacques1 Quote Link to comment https://forums.phpfreaks.com/topic/301173-call-to-undefine-function/#findComment-1532924 Share on other sites More sharing options...
gizmola Posted May 7, 2016 Share Posted May 7, 2016 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. Quote Link to comment https://forums.phpfreaks.com/topic/301173-call-to-undefine-function/#findComment-1532926 Share on other sites More sharing options...
gizmola Posted May 7, 2016 Share Posted May 7, 2016 Check out vagrant/virtualbox. Really helps with the iterative process, and addresses what Jacques is saying. Quote Link to comment https://forums.phpfreaks.com/topic/301173-call-to-undefine-function/#findComment-1532927 Share on other sites More sharing options...
gizmola Posted May 7, 2016 Share Posted May 7, 2016 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 Quote Link to comment https://forums.phpfreaks.com/topic/301173-call-to-undefine-function/#findComment-1532928 Share on other sites More sharing options...
Pikachu2000 Posted May 7, 2016 Share Posted May 7, 2016 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 . . . Quote Link to comment https://forums.phpfreaks.com/topic/301173-call-to-undefine-function/#findComment-1532935 Share on other sites More sharing options...
mindapolis Posted May 8, 2016 Author Share Posted May 8, 2016 got it Quote Link to comment https://forums.phpfreaks.com/topic/301173-call-to-undefine-function/#findComment-1532937 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.