I have a functions.php file with the following content.
function maxSavePerHour($ip, $maxSave = 15){
//DB connection and query. Working fine.
$totalRows = mysql_num_rows($res);
if($totalRows <=$maxSave){
$safe=true;
}else{
$safe=false;
}
if($safe){
echo "OK";
}else{
echo "Not OK";
}
}
I call that function from another page. And I use the function as following.
maxSavePerHour($ip, 5);
If I change the value the function echoes text as it should. The problem is the $safe variable. If I echo $safe i get nothing.
Any clues? The reason I need $safe to be true or false is because I use it in a if statement later.
I put global $safe;` and now its working. Thanks Nile.
global $safeat the beginning of your function, but I couldn't know without seeing the whole thing.$safevariable. Spontaneous guess: variable scope!var_dump($safe)?globalanywhere.