PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
So if my Session Var is greater than 0 he doesn't write the ECHO-Line
Why the hell doesn't he ?? if i leave this $_SESSION['u_lifc'] = 0; out than he does. Why does PHP set the session var to 0 before it outputs my Echo-Line!?!
Last edited by horgh on Mon Oct 21, 2002 9:59 am, edited 2 times in total.
because i only want to notify the user about that fact once he's seeing my page. when he then clicks on some link it should disappear in the next run of the script
should be only a small notification on login, not a message standing there for the whole session :/
Are you certain that your session variable has a value of '1'?
If it's a string, and not an integer, it will not prove greater than zero.
horgh wrote:Why the hell doesn't he ?? if i leave this $_SESSION['u_lifc'] = 0; out than he does. Why does PHP set the session var to 0 before it outputs my Echo-Line!?!
Secondly, how do you know your function is a he and not a she?
yes its value is an integer ...1,2, etc... cause it comes directly from a database entry. its datatype is INTEGER.
that isn't the point, 'cause when i leave this $_SESSION['u_lifc'] = 0; line out then it does prove that its greater than zero.
secondly, i meant the PHP Compiler and in german its a HE, so excuse me for not saying IT
I'd try your script on another server and see if you get the same output, because per the logic you have described thus far I put together a quick, little test script and the output was sound.
<?php
session_start();
$_SESSIONї'test'] = 1;
if($_SESSIONї'test'] > 0) {
echo "It is greater than zero.<br>";
$_SESSIONї'test'] = 0;
} else {
echo "It is not greater than zero.<br>";
}
if($_SESSIONї'test'] > 0) {
echo "It is greater than zero.<br>";
$_SESSIONї'test'] = 0;
} else {
echo "It is not greater than zero.<br>";
}
?>
This output to the browser:
It is greater than zero.
It is not greater than zero.
I am running PHP 4.2.3.
Thus, if you run your script on a subsidiary machine and run into the same problems you can be 99.9% sure it's something in your script because it's apparently not an issue in PHP.
yes i tested a similar script and it worked as well as i wanted my script to do that. it's logical that php puts out that message and then sets it to 0.
i have a function which tests another function called checklogin() which sets up the Sessionvariables if the user logs in correctly.
function login() {
GLOBAL $PHP_SELF,$login_name,$login_pass,$errormsg;
if(!checklogin($login_name,$login_pass)) {
$errormsg = "Login fehlgeschlagen!";
mysql_query("UPDATE users SET u_lifc=u_lifc+1 WHERE u_name = '$login_name'");
}
//else header("Location: ".$PHP_SELF);
}
i leave this else header.... out now and it works! I dont know why it works now, cause in both cases (with header and without) the next step in the script is the execution of that function which created this confusing output.
what has that header todo with my session variables ?!