0

Hello all,
i have been searching and now i am coming here to ask for some help.

can i use a php function in bind_param? If so, how can i go about doing it?

my function does have a return in it rather than an echo and when i echo the variable the function is bound to, it works.

$test = calc($var1,$var2);
echo $test;

function calc($var1,$var2) {
    blah blah
    return $somevar;
}
2
Contributors
2
Replies
20
Views
2 Months
Discussion Span
Last Post by michael.dewitt.716
2
$stmt->bind_param('sssd', $code, $language, $official, calc($v1, $v2) );

Should do it. However what happens if your function has an error? Needs to be able to deal with this. If the function is run before the binding and return value is placed in a variable it can be checked prior to doing anything with your db.

0

diafol, by god ole' chap you have done it again... lol i just forgot to put a = ? in the prepared statement for that col. I caught it when i switched the update statement to a string. Thanks again man.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.