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;
}
Member Avatar for diafol
$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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.