Jump to content

[solved] problam with time()


redarrow

Recommended Posts

for some unknown reason the if statement gives a error please advise me cheers.


[code]

<?php

$query_time="select * from member_comments where date_added='".$record['date_added']."' and

time_added='".$record['time_added']."' ";

$result_time=mysql_query($query_time);

while($timmed=mysql_fetch_assoc($result_time)){

$time_added=$timmed['time_added'];

$time_added=strtotime($time_added);

$time_know=(time()+120);

if($time_know > $time_added){

echo " sorry wait 2 minutes please";
}

?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/16665-solved-problam-with-time/
Share on other sites

$time_know=(time()+120);

can you tell me if this is the correct way to add 120 secons

database result


1154863305// from the database as a posted entry.

1154821215// time from time now.

looks very lomg and wrong to me there should only be 2 minutes between them both please help.
for some strange reason i am always getting the echoed message so i think i proberly not doing this correct i am trying to create a flood controll but not working becouse the word is always echoed.


[code]
$query_time="select * from member_comments WHERE time_added='$time_added' and date_added='$date_added' and user_id='$user_id'

";

echo $query_time;

$result_time=mysql_query($query_time);

while($timmed=mysql_fetch_assoc($result_time)){

$time_check=$timmed['time_sent'];
}

$check=strtotime($time_check);

echo "<br>$check<BR>";

$time_know=time() + 120;

echo "<br>$time_know<br>";

if($time_know > $check){

echo " sorry wait 2 minutes please";
exit;

}

[/code]
What am i doing wrong please been up all night read the hole php for dumies no luck.

the database is correct and all the settings are correct but the time diffrence does not seem to work please help cheers.

all i get is the echoed message as below cheers.

[code]
<?php
$query_time="select * from member_comments WHERE time_added='$time_added'
and date_added='$date_added' and user_id='$user_id'

";

echo $query_time;

$result_time=mysql_query($query_time);

while($timmed=mysql_fetch_assoc($result_time)){

$time_check=$timmed['time_sent'];
}

$check=strtotime($time_check);

echo "<br>$check<BR>";

$time_know=time() + 120;

echo "<br>$time_know<br>";

if($check < $time_know){

echo " sorry wait 2 minutes please";
exit;

}
?>
[/code]
solved



[code]
<?php
$query_time="select * from member_comments WHERE time_added='$time_added' and date_added='$date_added' and user_id='$user_id'
";

echo $query_time;

$result_time=mysql_query($query_time);

while($timmed=mysql_fetch_assoc($result_time)){

$time_check=$timmed['time_sent'];
}

$check=strtotime($time_check);

echo "<br>$check<BR>";

$time_know=time()-60;

echo "<br>$time_know<br>";

if($check > $time_know){

echo " sorry wait 2 minutes please";
exit;

}
[/code]

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.