- Edited
RayPooley think the error might be misleading.
The line
if($value = safe_value($conn, $seardh))
is an assignment.
I believe the code is supposed to be a comparison and so should use the == operator
if($value == safe_value($conn, $seardh))
Try that.
That wouldn't make a difference. The value of the assignment is still either whatever safe_value()
returns, so the if()
statement still takes the same branch. The only difference is that $value
is also assigned the same value, which is a good thing, since it is then used later in the then branch.
Using ==
wouldn't fix anything because now you're comparing the return value of safe_value()
with the value of a variable that doesn't even have a value yet. (You'd get an Undefined variable warning, and take the "safe value" branch only in the situation when safe_value()
returns false.)
And, of course, it wouldn't fix the reported problem that the safe_value
function wasn't even found in the first place.
I do notice another bug, though: safe_value()
will return a falsy value if $_GET[$name]
is '0'
. It may not be relevant in this instance (what does the "time
" column contain if time LIKE '%$value%'
is useful?) but since we're retrieving every record that contains a 1
in the description it would be churlish to not be doing the same for 0
. I think the return value should be checked more carefully:
if(($value = safe_value($conn, $search)) !== false)
or even separate testing-for-content and escaping-for-query into two separate functions.
But yes, like @NogDog says, if your pagination thing is on a different page then you'll need to get the function there as well, preferably by putting it another file and including it on every page you need it. If that's not what you're doing you'll need to explain what you are doing.