2017-08-07 56 views
-3

我对PHP并不擅长,我一直试图解决这个问题一个星期,没有运气。我对此不知所措

这是不工作的代码。

function sqlerror() 
{ 
    $this->fetch = mysqli_error(); 
    return $this->fetch; 
} 

function sqlerrno() 
{ 
    $this->fetch = mysqli_errno(); 
    return $this->fetch; 
} 

我不断收到此错误日志

mysqli_error()期望的是1个参数,0

mysqli_errno()给定期望的是1个参数,0

给出

这是什么意思,我该如何解决这个问题?

+1

你需要通过连接对象'mysqli_errno'功能'mysqli_errno($ connection_object_variable);在这些功能' – JYoThI

+0

通连接变量。 –

+0

给连接字符串作为一个参数'mysqli_error($ con)' –

回答

0

对于mysqli_error()mysqli_errno()您需要通过连接。

更新功能,可以这样做:

function sqlerror($connection) 
{ 
    $this->fetch = mysqli_error($connection); 
    return $this->fetch; 
} 

function sqlerrno($connection) 
{ 
    $this->fetch = mysqli_errno($connection); 
    return $this->fetch; 
} 

随着$connection是运行查询的数据库连接..

编辑 顺便说你不需要的功能检查对于错误。你可以做喜欢的事:

if (!mysqli_query($con,"INSERT INTO TABLE DATA")) 
{ 
    echo("Error description: " . mysqli_error($con)); 
} 
+0

我现在越来越期待参数1为mysqli,null给出,缺少参数1 – Etrixc

相关问题