Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我对函数的调用显然是错误的,我知道它';不是,但它';不清楚为什么_Php - Fatal编程技术网

Php 我对函数的调用显然是错误的,我知道它';不是,但它';不清楚为什么

Php 我对函数的调用显然是错误的,我知道它';不是,但它';不清楚为什么,php,Php,我正在尝试制作一个私人收件箱功能的教程,除了每次尝试按send时都会出现500个服务器错误之外,一切都进行得很顺利。我已经查看了可能导致此错误的日志,下面是我收到的信息:PHP致命错误:调用第17行/apps/bla/web/inboxPage.PHP中未定义的函数fetch_users_id(),referer:http://hinat.local/inboxPage.php 我已经检查了这个函数,看看是否有任何东西不合适,但无法发现任何可能会把它扔掉的东西 如果你能再给我一双眼睛看看我做错了

我正在尝试制作一个私人收件箱功能的教程,除了每次尝试按send时都会出现500个服务器错误之外,一切都进行得很顺利。我已经查看了可能导致此错误的日志,下面是我收到的信息:
PHP致命错误:调用第17行/apps/bla/web/inboxPage.PHP中未定义的函数fetch_users_id(),referer:http://hinat.local/inboxPage.php

我已经检查了这个函数,看看是否有任何东西不合适,但无法发现任何可能会把它扔掉的东西

如果你能再给我一双眼睛看看我做错了什么,我将不胜感激

提前谢谢

inboxPage.php:

<?php
 if(isset($_POST['to'], $_POST['subject'], $_POST['body'])){
   $errors = array();

   if(empty($_POST['to'])){
     $errors[] = 'You must enter at least one name.';
   } else if (preg_match('#^[a-z, ]+$#i', $_POST['to']) === 0){
     $errors[] = 'The list of names you gave does not look valid.';
   } else {
     $user_names = explode(',',$_POST['to']);

//Will remove and trailing spaces before and after name
     foreach ($user_names as &$name){
       $name = trim($name);
     }

     $user_id = fetch_users_id($user_names);

     if(count($user_id) !== count($user_names)){
       $errors[] = 'The following users could not be found: ' . implode(', ', array_diff($user_names, array_keys($user_id)));
     }
   }

   if(empty($_POST['subject'])){
     $errors[] = 'The subject cannot be empty.';
   }

   if(empty($_POST['body'])){
     $errors[] = 'The body cannot be empty.';
   }

   if(empty($errors)){

   }
 }

 if(isset($errors)){
   //Form has been submitted but errors have occured
   if(empty($errors)){
     echo '<div class="msg success"> Your message has been sent! <a href="inboxPage.php">Return to your Inbox</a></div>';
  //Form has been submittied and errors have occured
   } else {
     foreach ($errors as $errors) {
       echo '<div class="msg error">', $errors, '</div>';
     }
   }
 }
?>

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="site.css" >
<link href="https://fonts.googleapis.com/css?family=Lato:100,300,400" rel="stylesheet">
</head>

<body>

<!-- Header -->

<header class="primary-header container group">
  <h1 class="logo">
      <!-- <img src="../home/wendy/Pictures/Logo.png" alt="Website Logo"><br> -->
    <a href="index.php">  </a>
    </h1>

    <h3 class="tagline"> Cardiff, Wales </h3>

    <nav class="nav primary-nav">
      <ul>
        <li><a href="index.php">Home</a></li><!--
        --><li><a href="loginPage.php">Login</a></li><!--
        --><li><a href="registerPage.php">Register</a></li><!--
        --><li><a href="tutorPage.php">Tutors</a></li><!--
        --><li><a href="aboutPage.php">About Us</a></li><!--
        --><li><a href="contactPage.php">Contact Us</a></li>
      </ul>
    </nav>

</header>
<form action="" method= "post">

<section class="row">
<div class="grid">

  <div>
  <label for="to">To</label>
  <input type="text" name="to" id="to" value="<?php if (isset($_POST['to'])) echo htmlentities($_POST['to']); ?>" />
</div>

<div>
  <label for="subject">Subject</label>
<input type="text" name="subject" id="subject" value="<?php if (isset($_POST['subject'])) echo htmlentities($_POST['subject']); ?>" />
</div>

<div>
<textarea name="body" rows="20" cols="110"><?php if (isset($_POST['body'])) echo htmlentities($_POST['body']); ?></textarea>
</div>

<div>
  <input type="submit" value="send" />
</div>

</div>

</section>

</form>
<footer class="primary-footer container group">
  <small> &copy;</small>

  <nav class="nav">
    <ul>
      <li><a href="index.php">Home</a></li><!--
      --><li><a href="loginPage.php">Login</a><!--
      --><li><a href="tutorPage.php">Tutors</a><!--
      --><li><a href="registerPage.php">Register</a><!--
      --><li><a href="aboutPage.php">About Us</a><!--
      --><li><a href="contactPage.php">Contact Us</a>
      </ul>
  </nav>

</footer>

    </body>
    </html>

威尔士加的夫

inboxPage.php中不存在函数
fetch\u users\u id

如果要在该文件中使用该函数,则必须在inboxPage.php中包含或要求users.php

<?php
include("users.php");

inboxPage.php中不存在函数
获取用户id

如果要在该文件中使用该函数,则必须在inboxPage.php中包含或要求users.php

<?php
include("users.php");

如何将
users.php
包含在
inboxPage.php
中?inboxPage.php中是否包含“users.php”?inboxPage.php中不需要或不包含users.php。我得检查一下!谢谢。如何将
users.php
纳入
inboxPage.php
??inboxPage.php中是否包含“users.php”?inboxPage.php中不需要或不包含users.php。我得检查一下!谢谢,你原来的问题已经回答了。您应该将此标记为已接受,然后打开另一个问题。您原来的问题已得到回答。您应该将此标记为已接受,然后打开另一个问题。