Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.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 调用未定义的函数dbtrim()_Php - Fatal编程技术网

Php 调用未定义的函数dbtrim()

Php 调用未定义的函数dbtrim(),php,Php,我有一个用于登录的表单,我用ajax捕获发布的数据。然后将其发布到logincheck.php。它从db.php调用函数,db.php包含在我的index.php的第一行中,但在我开始使用ajax之后,它开始给出类似以下的错误: 致命错误:在第6行的D:\xampp\htdocs\include\logincheck.php中调用未定义的函数dbtrim() 我是PHP的新手,知道基本的代码。所以请详细解释一下这有什么问题。谢谢 下面是我如何从logincheck.php调用函数 if($_PO

我有一个用于登录的表单,我用ajax捕获发布的数据。然后将其发布到logincheck.php。它从db.php调用函数,db.php包含在我的index.php的第一行中,但在我开始使用ajax之后,它开始给出类似以下的错误:

致命错误:在第6行的D:\xampp\htdocs\include\logincheck.php中调用未定义的函数dbtrim()

我是PHP的新手,知道基本的代码。所以请详细解释一下这有什么问题。谢谢

下面是我如何从logincheck.php调用函数

if($_POST) {

    $KullaniciAdi = strip_tags(trim(dbtrim($_POST["KullaniciAdi"])));
    $Sifre = strip_tags(trim(dbtrim($_POST["sifre"])));
php函数

function dbtrim($par) {
    return str_replace(array("'","\""), array("'","""), $par);
}
Ajax代码


$(函数(){
$(“#btnGiris”)。单击(函数(){
var$txtKullaniciAdi=$(“.KullaniciAdi”);
变量$txtSifre=$('.sifre');
如果($txtKullaniciAdi.val().trim().length==0){
$('.sonuc').fadeIn(200).addClass(“hata”).html(“”);
$('.sonuc').html(“Kullanıcıadınıboşbırakamassınız..);
}else if($txtSifre.val().trim().length==0){
$('.sonuc').fadeIn(200).addClass(“hata”).html(“”);
$('.sonuc').html(“ifreyi boşbırakamassınız.);
}否则{
var veriler=$(this.serialize()+“&”+$.param({KullaniciAdi:$txtKullaniciAdi.val(),Sifre:$txtSifre.val()});
$.ajax({
类型:“POST”,
url:“include/logincheck.php”,
资料来源:veriler,
数据类型:“json”,
成功:功能(数据){
如果(data.Sonuc==“Hata1”){
$('.sonuc').fadeIn(200).addClass(“hata”).html(“”);
$('.sonuc').html(data.Mesaj)
}else if(data.Sonuc==“Hata2”){
$('.sonuc').fadeIn(200).addClass(“hata”).html(“”);
$('.sonuc').html(data.Mesaj)
}否则{
location.reload();
}
},
错误:函数(xmlHttpRequest、状态、错误){
警报(xmlHttpRequest.statusText+''+xmlHttpRequest.status+':'+xmlHttpRequest.responseText);
}
});
}
});
});

logincheck.php
文件中,您应该包含
DB.php
,以便可以使用
DB.php
中定义的函数

您可以通过在DB.php文件的顶部添加下面的代码来实现这一点

<?php include("DB.php"); ?>


关于在项目中使用PHP
include
搜索“
function dbtrim
”的一个很好的参考,而不是
include\u once
该文件可能会对您有所帮助。

该错误仅仅意味着您在logincheck.PHP页面中调用的
dbtrim
函数不是标准的,也没有在代码中定义。您是否错过了一个include?正如我所说,我在index.php的第一行中包含了db.php,java也在index.php中,它将数据发布到logincheck.php。然后我得到了那个错误。include中的路径正确吗?它们在同一个目录中。我再次删除了JavaScript标记。PHP和JavaScript是完全不同的语言(在本例中)甚至不会在同一台计算机上运行。一个未定义的函数服务器端PHP致命错误不能由客户端Javascript引起。然后我得到这个错误,因为它已经包含在index.PHP的第一行中。致命错误:无法在线重新声明D:\xampp\htdocs\db.php中的idval()(以前在D:\xampp\htdocs\db.php:51中声明)54@AlperKöse Do
只包含一次
<代码>仍然是相同的错误,但我意识到如果我只在logincheck.php中包含db.php,它会给出错误,但不是因为函数。我可能会这样做,但为什么在index.php中包含该函数时无法调用它呢?@AlperKöse该结构有点混乱。Ajax代码位于
index.php
中?是的,它位于index.php中