Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mysqli_affected_rows() expects parameter 1 to be mysqli, boolean given #7176

Closed
BrickOzp opened this issue Dec 7, 2021 · 2 comments · Fixed by #7177
Closed

mysqli_affected_rows() expects parameter 1 to be mysqli, boolean given #7176

BrickOzp opened this issue Dec 7, 2021 · 2 comments · Fixed by #7177
Milestone

Comments

@BrickOzp
Copy link
Contributor

BrickOzp commented Dec 7, 2021

Description

Error found in error log

mysqli_affected_rows() expects parameter 1 to be mysqli, boolean given

#0: smf_error_handler()
Called from unknown on line -1
#1: mysqli_affected_rows()
Called from /Sources/Subs-Db-mysql.php on line 513
#2: smf_db_affected_rows()
Called from /Sources/Session.php on line 242
#3: sessionGC()
Called from unknown on line -1
#4: session_start()
Called from /Sources/Session.php on line 81
#5: loadSession()
Called from /index.php on line 184

Steps to reproduce

  1. Don't know

Environment (complete as necessary)

  • Version/Git revision: 12bf435
  • Database Type: MySql
  • Database Version:
  • PHP Version: 7.1

Additional information/references

@BrickOzp
Copy link
Contributor Author

BrickOzp commented Dec 7, 2021

In Session.php

$session_update = $smcFunc['db_query']('', '

235: | DELETE FROM {db_prefix}sessions
236: | WHERE last_update < {int:last_update}',
237: | array(
238: | 'last_update' => time() - $max_lifetime,
239: | )
240: | );
241: |  
==>242: | return ($smcFunc['db_affected_rows']( $session_update ) == 0 ? false : true);

smf_db_affected_rows() -> mysqli_affected_rows() expects a connection, but here we pass it a query result.

@sbulen
Copy link
Contributor

sbulen commented Dec 7, 2021

This usually means there was a connection error. So connect returns false instead of a resource, and when you try to use that result in a query, this message pops up.

You need to figure out why you couldn't connect...

BrickOzp added a commit to BrickOzp/SMF2.1 that referenced this issue Dec 7, 2021
db_affected_rows expects a connection object.
Remove parameters of type query result.

Fixes SimpleMachines#7176

Signed-off-by: Oscar Rydhé <oscar.rydhe@gmail.com>
@Sesquipedalian Sesquipedalian added this to the 2.1.0 milestone Dec 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants