php - Bind_param() on a non-object-error when using variables as input -
php - Bind_param() on a non-object-error when using variables as input -
trying update using mysqli, calling class function this:
$nyvaegt = 10; $navn = 'ord'; $nyoevelse = new oevelse(); $nyoevelse->opdateroevelse( $nyvaegt, $navn );
and corresponding class function:
public function opdateroevelse ( $nyvaegt, $navn) { $this->nyvaegt = $nyvaegt; $this->navn = $navn; global $mysqli; $stmtopdateroevelseihistorik = $mysqli->prepare("update oevelser set `vaegt12reps`=? `navn`='?' values (?, ?)"); var_dump($stmtopdateroevelseihistorik); $stmtopdateroevelseihistorik->bind_param( "ds", $nyvaegt, $navn); $stmtopdateroevelseihistorik->execute(); if ( $stmtopdateroevelseihistorik ) echo "query success!<br>"; else echo "query failed!<br>"; }
if run this, fails saying that:
call fellow member function bind_param() on non-object
the error refers line:
$stmtopdateroevelseihistorik->bind_param(
var_dump responds: bool(false)
so, goes wrong while binding parameters, seems.
if bypass variables , phone call this:
$stmtopdateroevelseihistorik = $mysqli->prepare("update oevelser set `vaegt12reps`=100 `navn`='ord'");
it works fine...
tried kinds of '', ""-variations, can't create work... - advice people of so...?
far know, update doesn't utilize values:
http://dev.mysql.com/doc/refman/5.0/en/update.html
insert does: http://dev.mysql.com/doc/refman/5.6/en/insert.html
plus, remove quotes in ='?'
main cause for:
call fellow member function bind_param() on non-object
change existing line following:
$stmtopdateroevelseihistorik = $mysqli->prepare("update oevelser set `vaegt12reps`=? `navn`=?");
php mysqli
Comments
Post a Comment