我的代码中存在问题。当我尝试在我的应用程序中搜索哪个错误
时致命错误:未捕获错误:在C:\ xampp \ htdocs \ newspaper \ cpannel \ ajaxcat.php中调用未定义的方法
public static function SearchOnCategorya($data) { global $dbh; $sql=$dbh->prepare("select * from category where name like '%$data%'"); if($sql->execute()){ $allcategories = $sql->fetchall(PDO::FETCH_ASSOC); return $allcategories; }else{ return FALSE; } }
:210堆栈跟踪:#0 {main}在C:\ xampp \中抛出第210行的htdocs \ newspaper \ cpannel \ ajaxcat.php
这是我的班级类别代码
$(function (){
$("#catserch").on("keyup",function (){
var serach=$(this).val();
var action="searchcategory";
$.ajax({
url: "ajaxcat.php",
method: "post",
data: {action: action, serach:serach},
beforeSend: function () {
$(".img-ad").fadeIn();
},
success: function (data) {
$(".serchresult").html(data);
$(".img-ad").fadeOut();
},
error: function () {
$(".serchresult").html("error");
$(".img-ad").fadeOut();
}
})
})
})
这是jQuery和ajax代码
case'searchcategory':
echo $data=$_POST['serach'];
echo '<table class="table table-striped table-bordered table-hover">
<thead>
<th>id</th>
<th>name</th>
<th>manager</th>
</thead>
<tbody>';
$allcattt= category::SearchOnCategorya($data);
print_r($allcattt);
if(is_array($allcattt)&& count($allcattt)>0){
foreach ($allcattt as $category):
echo'
<td> '.$category['id'].'</td>
<td> '.$category['name'].'</td>
<td> '.editor::retriveeditornamebyid($category['id_manager']).'</td>
</tbody>
</table>';
endforeach;
}else{
}
break;
这是我的PHP代码:
<?php
require_once '../config.php';
class category {
private $id;
private $name;
private $id_manager;
public function __construct($name, $id_manager, $id = "") {
$this->name = $name;
$this->id_manager = $id_manager;
$this->id = $id;
}
public function addcategory() {
global $dbh;
$sql = $dbh->prepare("insert into category (name,id_manager)values('$this->name','$this->id_manager')");
if ($sql->execute()) {
return true;
} else {
return FALSE;
}
}
public static function retrieveAllCategories() {
global $dbh;
$sql = $dbh->prepare("select * from category order by id desc limit 0,10");
if ($sql->execute()) {
$allcategories = $sql->fetchall(PDO::FETCH_ASSOC);
return $allcategories;
} else {
return false;
;
}
}
public static function deletecategorybyid($id) {
global $dbh;
$sql = $dbh->prepare("delete from category where id='$id'");
if ($sql->execute()) {
return true;
} else {
return FALSE;
}
}
public static function retrivecategorybyid($id) {
global $dbh;
$sql = $dbh->prepare("select * from category where id= '$id'");
if ($sql->execute()) {
$category = $sql->fetch(PDO::FETCH_ASSOC);
return $category;
} else {
return false;
}
}
public function updatecategorybyid() {
global $dbh;
$sql = $dbh->prepare("update category set name='$this->name',id_manager='$this->id_manager' where id='$this->id'");
if ($sql->execute()) {
return true;
} else {
return FALSE;
}
}
public static function RetriveTotalCategoryCount() {
global $dbh;
$sql = $dbh->prepare("select id from category");
if ($sql->execute()) {
return $sql->rowcount();
} else {
return false;
}
}
public static function RetriveLatestInsertCategoryId() {
global $dbh;
$sql = $dbh->prepare("SELECT id FROM category ORDER BY id DESC limit 1");
if ($sql->execute()) {
$all = $sql->fetch(PDO::FETCH_ASSOC);
return $all['id'];
} else {
return false;
}
}
public static function RetriveCategoryNameBYID($id) {
global $dbh;
$sql = $dbh->prepare("SELECT name FROM category where id ='$id'");
if ($sql->execute()) {
// $name=$sql->fetch(PDO::FETCH_ASSOC);
$name = $sql->fetch(PDO::FETCH_ASSOC);
return $name['name'];
} else {
return false;
}
}
public static function xy() {
global $dbh;
$sql = $dbh->prepare("SELECT id FROM category ");
if ($sql->execute()) {
return $dbh->lastInsertId();
} else {
return false;
}
}
public static function retrieveAllCategoriesxx() {
global $dbh;
$sql = $dbh->prepare("select * from category ");
if ($sql->execute()) {
$allcategories = $sql->fetchall(PDO::FETCH_ASSOC);
return $allcategories;
} else {
return false;
;
}
}
public static function RETRIVEnumberOFCATEGORIESMANGEDBYidmanager($id_manager) {
global $dbh;
$sql = $dbh->prepare("select id from category where id_manager='$id_manager'");
if ($sql->execute()) {
return $sql->rowcount();
} else {
return FALSE;
}
}
public static function RetriveAllCategoriesidMangedbyIDManager($id_manager) {
global $dbh;
$sql = $dbh->prepare("SELECT id FROM category WHERE id_manager='$id_manager'");
if ($sql->execute()) {
$allCategories = $sql->fetchAll(PDO::FETCH_ASSOC);
if (is_array($allCategories) && count($allCategories) > 0) {
$allCategoriesId = null;
foreach ($allCategories as $category):
$allCategoriesId[] = $category['id'];
endforeach;
return $allCategoriesId;
}else {
return false;
}
} else {
return false;
}
}
public static function Rtrivecategorymangertbycategoryid($id)
{
global $dbh;
$sql = $dbh->prepare("SELECT id_manager FROM category WHERE id='$id'");
if($sql->execute()){
$category = $sql->fetch(PDO::FETCH_ASSOC);
if(is_array($category)){
return $category['id_manager'];
}else{
return false;
}
}else{
return false;
}
}
public static function SearchOnCategory($data)
{
global $dbh;
$sql=$dbh->prepare("select * from category where name like '%$data%'");
if($sql->execute()){
$allcategories = $sql->fetchall(PDO::FETCH_ASSOC);
return $allcategories;
}else{
return FALSE;
}
}
}
这是班级类别:
import numpy as np
def strange(S, T, U, V):
d = 0
print min(np.abs(S[d]), np.abs(T[d]), U[d], V[d])
答案 0 :(得分:0)
在你的课堂上,你有:
public static function SearchOnCategory($data)
在通话中,您有:
SearchOnCategorya
请注意您的通话中的额外字母a
?你拼错了这个函数。