[PHP] Annoying Substraction Problem
Okey, so I'm having some problems with something that seems like a simple piece of code. the problem is that I can't get it to work :scratch:
PHP Code:
$result = mysql_db_query($db_name, "SELECT * FROM ".$db_prefix."users WHERE username = '$username'") or die (mysql_error());
if (mysql_num_rows($result)) {
while ($get = @mysql_fetch_array($result)) {
$timedone = $get[done];
$time = time() - $timedone;
if($time <= 200) {
echo 'You must wait '.$time.' seconds before you can continue';
} else { header('location: main.php'); }
}
}
I want it to take a number from a MySQL database and substract it from the current time()
But it just echos 0 and doesn't do anything :S
Re: [PHP] Annoying Substraction Problem
What is $get[done] supposed to mean?
Re: [PHP] Annoying Substraction Problem
It fetches the info from a MySQL column called done
Re: [PHP] Annoying Substraction Problem
If i am not mistaken this:
PHP Code:
$timedone = $get[done];
should actually be:
PHP Code:
$timedone = $get['done'];
That's likely causing the problem.
Re: [PHP] Annoying Substraction Problem
yupp lol xD
Thanks :D
I hate when I do those mistakes xD
Re: [PHP] Annoying Substraction Problem
Advice: take a very very close look at the point of the error, character per character. Then you'll often notice it.
Also, a syntax highlighter helps, as then you can see something is wrong (something between [ and ] is either a string, number or variable).
Re: [PHP] Annoying Substraction Problem
I know, the things is that I actually do that but my mind sort of just skips the part that contains the error -.-
if you look at a previusly posted topic, you can se that I made another small spelling mistake xD