but this is the result after entering more than 15 characters in the first field. I cant figure out why the page gets redirected to index2.php?error=5 and not simply index2.php?error=1
No, thatās not entirely true. You are most likely thinking about num_rows or rowCount. In order to get the returned value from your function, you have to compare it to true or false. There is no automac for conditions youāve made yourself. If you take a look at this snippet, this is what it sees.
if(function_name($param1, $param2)) {
// What you really wanted it to do when it's true.
// Sees the function is defined.
// No matter what it originally returns, both returned values will end up being in here.
} else {
// What you really wanted it to do if it's false.
}
You have to compare what you want in the first condition in order for it to correctly check.
if(function_name($param1, $param2) == true) {
// What you really wanted it to do when it's true.
} else {
// What you really wanted it to do if it's false.
}
die() and exit() both are the same. Just depends on user preference. Also, be consistent when you use these 2 functions. Donāt use exit() in one file and then use die() in another and then include them both in a single file. This makes it really confusing to determine which one you really want to use.
so now Iām not sure what you meant above. My function appears to be able to be used without a direct comparison and work the way I expected it to. Or am I misunderstanding?
I am not eniterly sure how it works too. If you attempt to use it without the for loop, it will most likely not work. But if you throw it in a for loop, it looks to behave how you want it to. It doesnāt work without that which is odd.
Wait, I might of been wrong. But I am not entirely sure. When I wrote this, I was on my phone. I didnāt test it out and it might of been the OP missing the die that actually was not working. Iāll have to go back and test it out when I have a chance.
I think that bit is certainly correct - I didnāt notice that, I scrolled past too quickly and was more intent on banging on about how the var_dump() might have stopped the header relocate working due to previous output.
I am not sure about the Boolean return thing, only noticed that quite a few questions on the web use that without noting any issues.