@klemme
whats wrong with this prepared statement?
This wrong:
$ADJUST_PREP = mysqli_stmt_prepare($connection, $ADJUST);
$ADJUST_PREP = mysqli_stmt_bind_param($ADJUST_PREP, "i", $pos_op);
$pos_op = $_GET['pos'];
$pos_op = $pos_op + 1;
Why are you using $ADJUST_PREP & $pos_op twice but different variable?
You only used it one time! The reason the error come up because mysqli_stmt_execute statment is confused of which statement to used because it's using both at the same time:
$ADJUST_PREP = mysqli_stmt_prepare($connection, $ADJUST);
-and
$ADJUST_PREP = mysqli_stmt_bind_param($ADJUST_PREP, "i", $pos_op);
So another words your mysqli_connect probably didn't work.
I assume that $connection is your mysqli_connect
You need to rename one of those $ADJUST_PREP & $pos_op to a different name so it won't get confused.
LastMitch
Industrious Poster
4,165 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45
@klemme
$ADJUST = "UPDATE modul_galleri SET pos = pos - 1 WHERE pos = ?";
$ADJUST_PREP = mysqli_stmt_prepare($connection, $ADJUST);
$ADJUST_STMT_PREP = mysqli_stmt_bind_param($ADJUST_PREP, "i", $pos_op);
$pos = $_GET['pos'];
$pos_op = $pos + 1;
mysqli_stmt_execute($ADJUST_STMT_PREP);
mysqli_stmt_free_result($ADJUST_STMT_PREP);
mysqli_stmt_close($ADJUST_STMT_PREP);
If I set to to fixed values, it updates just fine, but with the variables the error comes back again?
Yes it looks right now have you test it out Yet?
Starting to see double after a long day here, bur I hope to fix it before stopping for the day..
I get it and I understand. It should work now. You did this very quickly. You won't get this error anymore:
mysqli_stmt_execute() expects parameter 1 to be mysqli_stmt, boolean
LastMitch
Industrious Poster
4,165 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45
@klemme
Hmm, the $connection should be fine though..
It shouldnt be this hard, but somehow it is..
I agree with you.
Can you post your query for your connection.
Do you have this @ in front of your mysqli connection?
Try to put these `` quotes on your query
LastMitch
Industrious Poster
4,165 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45
@klemme
Any idea why mysqli_stmt_bind_param is creating this error?
For the "i", change to this 'i'
From this
$ADJUST_STMT_PREP = mysqli_stmt_bind_param($ADJUST_PREP, "i", $pos_op);
to this
$ADJUST_STMT_PREP = mysqli_stmt_bind_param($ADJUST_PREP, 'i', $pos_op);
Instead of this using mysqli_stmt_free_result():
mysqli_stmt_free_result($ADJUST_STMT_PREP);
Try used mysqli_stmt_get_result():
mysqli_stmt_get_result($ADJUST_STMT_PREP);
Try it now.
So everything you change
$ADJUST = "UPDATE modul_galleri SET pos = pos - 1 WHERE pos = ?";
$ADJUST_PREP = mysqli_stmt_prepare($connection, $ADJUST);
$ADJUST_STMT_PREP = mysqli_stmt_bind_param($ADJUST_PREP, 'i', $pos_op);
$pos = $_GET['pos'];
$pos_op = $pos + 1;
mysqli_stmt_execute($ADJUST_STMT_PREP);
mysqli_stmt_get_result($ADJUST_STMT_PREP);
mysqli_stmt_close($ADJUST_STMT_PREP);
LastMitch
Industrious Poster
4,165 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45
I think $pos_op should go before the statement, because it still doesn't exists and so this will give a boolean FALSE value when you try to send it to mysqli, so try to change the order:
$pos = $_GET['pos'];
$pos_op = $pos + 1;
$adjust = "UPDATE modul_galleri SET pos = pos - 1 WHERE pos = ?";
$ADJUST_PREP = mysqli_stmt_prepare($connection, $adjust);
$ADJUST_STMT_PREP = mysqli_stmt_bind_param($ADJUST_PREP, "i", $pos_op);
bye!
cereal
Veteran Poster
1,145 posts since Aug 2007
Reputation Points: 344
Solved Threads: 222
Skill Endorsements: 22
Question Answered as of 6 Months Ago by
LastMitch
and
cereal