Jump to content

php maths help


jamesxg1

Recommended Posts

Get out of the habit of quoting everything.

 

If you want to add two numbers together use:

$new = $time + $timeout;

not

$new = "$time + $timeout";

 

Also ensure that you are actually setting $_SESSION['time']

 

Damn my bad lol, sorry i was trying every way possible last night to get it working and must not of removed the quotes lol, and the $_SESSION['time']; var is set with the login time. 100#% working

Link to comment
https://forums.phpfreaks.com/topic/153458-php-maths-help/#findComment-806245
Share on other sites

if ($time = $new) {

will set the value of $time to the value of $new, and then execute the if logic

 

if ($time == $new) {

will compare the value of $time with the value of $new and only execute the if logic if the two values are equal

 

correct, iv changed it and all i get now is

 

1239358810

1239358810 + 2

Link to comment
https://forums.phpfreaks.com/topic/153458-php-maths-help/#findComment-806252
Share on other sites

this is the code, but i cant get no results here  :(

You won't see any results because you're only printing results if $time and $new are the same... but they're not going to be the same because $new is 2 more than $time

 

if ($time == $new) {
   print $time.' and '.$new.' are the same';
} else {
   print $time.' and '.$new.' are not the same';
}

Link to comment
https://forums.phpfreaks.com/topic/153458-php-maths-help/#findComment-806583
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.