PHP Fatal error: Call to undefined function?

Nick Leeman

So i have a problem with my website when im hosting it on my webhost. i get this error:

PHP Fatal error:  Call to undefined function getSkillIcons()

The weird thing is that locally(Xampp) it works just fine.

This is how i included the function(in index.php):

<?php include 'http://sub.website.com/incl/Settings.php'; ?>

this is where i call it (index.php):

<div class="panel-body" style="text-align:center">
<?php getSkillIcons(explode(',', skills)); ?>
</div>

This how i defined skills (settings.php)

define("skills", "Test1,Test2,Test3,Test4");

this is the function itself: (settings.php)

function getSkillIcons($skills) {
    echo '<a href="?skill=Overall" title="Overall" data-toggle="tooltip"            data-placement="top"><img src="http://sub.website.com/incl/img/skill_icons/Overall-icon.png" class="skill-icon"></a>';
    for ($i = 0; $i < count($skills); $i++) {
        $tooltip = 'title="'.$skills[$i].'" data-toggle="tooltip" data-placement="top"';
        echo '<a href="?skill='.$skills[$i].'" '.$tooltip.'><img src="http://sub.website.com/incl/img/skill_icons/'.$skills[$i].'-icon.png" class="skill-icon"></a>';
    }
Amit Gupta

Call to undefined function error clearly shows that its not getting your function where you have defined. Reason is you are attaching full path of settings.php file with http.

You need to include settings.php file without http path at the top of 'index.php' and make sure settings.php file is located in your project only. If it is located at the same folder with index.php, then simply include like below.

<?php include 'settings.php'; ?> 

If your settings.php file is located in some other website but in your same server then you can use $_SERVER['DOCUMENT_ROOT'] to include that file like below:

<?php 
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/yourpath/settings.php";
include_once($path);
?>

If your settings.php file is located in some other website and some other server then you need to update allow_url_include=On in your php.ini that is the MAJOR SECURITY RISK. So, if you trust the website then only do it.

// Extremely insecure:
<?php include("http://sub.website.com/incl/Settings.php"); ?>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

PHP Fatal error: Call to undefined function Laravel tinker

PHP Fatal error: Call to undefined function json_decode()

php - Fatal error: Call to undefined function mcrypt_get_iv_size() in AppServ

PHP Fatal error: Call to undefined function imagecreatefrompng()

Wordpress - PHP Fatal error: Call to undefined function get_bloginfo()

Fatal error: Uncaught Error: Call to undefined function ereg_replace() PHP 7

Deployer - Fatal error: Call to undefined function server()

Call to undefined function iconv() fatal error - Suitecrm

In PHP 7.0 Fatal error: Uncaught Error: Call to undefined function json_encode()

Fatal error: Call to undefined function gmp_sign() in php

PHP Fatal error: Call to undefined function json_decode() on Cpanel

CodeIgniter PHP Fatal error: Call to undefined function form_open()

Fatal error: Call to undefined function gregoriantojd() in docker PHP

Fatal Error: Call to undefined function imap_open PHP

Fatal error: Call to undefined function normalizamyway() php abstract class

Fatal Error: Call to undefined function curl()

PHP Error: Fatal error: Call to undefined method

PHP Classes - Fatal error: Call to undefined method

PHP: Fatal error: Call to undefined method mysqli

Fatal error: Call to undefined function bindParam()

phpMyAdmin Fatal error: Call to undefined function __()

PHP to Postgres - Fatal error: Call to undefined function pg_connect()

Fatal error: Call to undefined function

PHP Fatal error : Call to undefined function mysql_connect()

PHP Fatal error: Call to undefined function curl_init()

PHP Fatal error: Call to undefined function pdo_query()

Fatal error: Call to undefined function runQuery()

PHP Fatal error: Uncaught Error: Call to undefined function mssqli_fetch_assoc()

Fatal error: Uncaught Error: Call to undefined function redirect() PHP logout session