Jump to content
MakeWebGames

Time Problems


Razor42

Recommended Posts

Hi guys,

I am currently creating a mod and I am having a few issues with time() and wondered if you’s could maybe help me out.

Basically the users sets a time how long they want it to be (Minutes) here...

 

Time (Minutes): <input type='text' name='time' value='Time....' /><br />

 

Then when storing the time in the DB I’m doing...

 

$time = abs((int) $_POST['time']);
$mtime = $time*60; //To turn the time from seconds to minutes
$btime = time()+$mtime;

 

Then when printing the time I am getting the time remaining as -202 (As an example) instead of something like 20 mintues?

Any know why this is?

Cheers.

Link to comment
Share on other sites

Unfortunately the mod is being done in MySQL not MySQL(i)

No offense, but this is why most people get flamed.

Did you try it in mysql? No.

Did you try it in phpmyadmin? No.

Will it work with mysql? Yes.

Will it work in phpmyadmin? Yes.

Why will it work? Because it still uses MySQL driver. Mysqli is a framework for mysql.

How do i get it to work? Change mysqli_query to mysql_query.

Link to comment
Share on other sites

I don’t see why that would get me flamed?

The reason people usually get flamed around here is because they come asking questions on how to do everything and expect everything given to them whereas I have actually done a lot of coding, I have contributed mods to the community and I do the majority of my work without having to ask a

Question.

I obviously don’t know much about mysqli which is why I thought it wouldn’t work. I will now go test it and see if it does work.

- - - Updated - - -

There is also the problem it’s not updating the users field it’s being inserted into the DB...

The current query is...

$db->query("INSERT INTO bounty (id, poster, targetn, target, money, time) VALUES ('', '{$userid}', '{$ft['username']}', '{$target}', '{$prize}', '{$btime}')");

 

So how would I go about doing that?

Link to comment
Share on other sites

I have resolved the initial error.

Now I have another one...

The time is currently displaying in seconds like 300 but I want it in minutes so it should be 5 right?

How would I do this?

If its displaying in seconds correctly.

300/60 = 5

$minutes = intval($database['seconds'] / 60);

should do it.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...