0

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

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";
        }

我怎样才能避免该警告信息?

4

1 回答 1

0

这是因为您的呼叫mysqli_prepare()失败。该函数在失败时返回 false。

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

于 2013-08-17T12:13:26.770 回答