gpt4 book ai didi

php - php mysql错误/警告中的自定义消息

转载 作者:行者123 更新时间:2023-11-30 01:23:25 24 4
gpt4 key购买 nike

我在 mysql 中有几个月的表。当我将下面的代码用于数据库中不存在的表名时,我想将自定义消息显示为“无效月份”。但除了此消息之外,我还收到一条警告:

Warning: mysqli_stmt_execute() expects parameter 1 to be mysqli_stmt, boolean given in C:\xampp\htdocs\student_portal\admin\update_attd.php on line 102

i 根据用户输入动态生成表名

 $sql="SELECT * FROM `tablename`";
$stmt = mysqli_prepare($con, $sql);
if(!mysqli_stmt_execute($stmt)){ //this is the line that shows the warning
echo " invalid month";
}

如何避免出现该警告消息?

最佳答案

这是因为您对 mysqli_prepare() 的调用失败。函数失败时返回 false。

http://php.net/manual/en/mysqli.prepare.php

关于php - php mysql错误/警告中的自定义消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18288662/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com