dongpin1059 2015-01-31 17:49
浏览 27

调用未定义的函数select_leverancier_specific()

I have 2 functions that I can request with an url parameter. the strange thing is that one function is working while the other isn't.

this is my select.php code:

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

// This function will select all data where productid is the same as the provided product id
function select_product_specific($productid)
{
  GLOBAL $mysqli, $prefix;
  $stmt = $mysqli->prepare("SELECT
                            *
                            FROM " . $prefix . "product
                            WHERE productid = ?");
  $stmt->bind_param("i", $productid);
  $stmt->execute();
  $stmt->bind_result($productid, $productnaam, $productomschrijving);
  while($stmt->fetch())
  {
    $row[] = array('productid' => $productid, 'productnaam' => $productnaam, 'productomschrijving' => $productomschrijving);
  }
  $stmt->close();
  return($row);
}

function select_leverancier_specific($levid)
{
  GLOBAL $mysqli, $prefix;
  $stmt = $mysqli->prepare("SELECT
                            levid,
                            levnaam,
                            adres,
                            postcode,
                            woonplaats,
                            land,
                            telefoonnummer
                            FROM " . $prefix . "leverancier
                            WHERE levid = ?");
  $stmt->bind_param("i", $levid);
  $stmt->execute();
  $stmt->bind_result($levid, $levnaam, $adres, $postcode, $woonplaats, $land, $telefoonnummer);
  while($stmt->fetch())
  {
    $row[] = array('levid' => $levid, 'levnaam' => $levnaam, 'adres' => $adres, 'postcode' => $postcode, 'woonplaats' => $woonplaats, 'land' => $land, 'telefoonnummer' => $telefoonnummer);
  }
  $stmt->close();
  return($row);
}
?>

I can request the function in request.php:

    <?php
// Require file with connection to database
require_once('../connection/connect.php');
// Requite file with functions
require('../core/select/select_all.php');
require('../core/select/select.php');

// This file handles the request an app sends
// It will check what kind of function is requested,
// if the function needs some param's
// and then json_encode the output

@$function = $_GET['function'];
@$param = $_GET['param'];



if(!isset($_GET['function']))
{
  $array = array('error' => 'Geen functie is aangeroepen!');
  return json_encode($array);
}
elseif(!isset($_GET['param']))
{
  var_dump(json_encode($function()));
}
else
{
  ### place 1 ###
  var_dump(json_encode($function($param)));
}
?>

when enter the following url

request.php?function=select_leverancier_specific&param=1

I get the following error:

Fatal error: Call to undefined function select_leverancier_specific() in ... line 29

Line 29 is

  var_dump(json_encode($function($param)));

when I place the function select_leverancier_specific($levid) on the ###place 1### placeholder, I get the correct result.

when I request select_product_specific($productid) I get the correct result.

Does someone know where my error is?

Thanks a lot in advance!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测