mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean with mysqli

后端 未结 2 1523
花落未央
花落未央 2020-12-22 08:21

I am not able to get the warning the sql query is working and mysqli_query() returns 1 and each time my database is also being updated . What is the problem?

相关标签:
2条回答
  • 2020-12-22 08:31

    According to another question here :

    The INSERT command will return a boolean(true/false), So you must use select command to get the required result

    0 讨论(0)
  • 2020-12-22 08:33

    The error that you're getting is because the INSERT query failed, so mysqli_query() has returned false to indicate that the query has failed. A successful query would have returned a mysqli_result() object. Check the contents of $sql1 for anything like syntax errors.

    You can use mysqli_error() after the insert query to get the error that's being returned by MySQL.

    btw, you're wide open to SQL Injection attack! The value for $tval is coming straight from the user without any attempt to validate or sanitize it! You should use prepared statements.

    0 讨论(0)
提交回复
热议问题