Jump to content

Recommended Posts

its not working.. it just echos "success!" even when i just posted a second ago.  The only time i should see "success" is after 50 seconds.. Where did i go wrong?

 

$username = $_SESSION['username'];
  mysql_connect("localhost", "Master", "password");
mysql_select_db("dbk");
$result = mysql_fetch_assoc(mysql_query("SELECT * FROM Stacks"))or die (mysql_error());
$user = $result['username'];
$time = $result['posted'];

if ( ($time > (time()-50)) && ($username == $user) )

    {
  echo "<font color=white>You must wait 30 seconds between submits</font>";
}

else {
echo "Success!";
}

Add this debugging line to your code just before your IF statement

 

echo "The value of my variable $time is : ".$time." The value of time() is : ".time()." The difference between the two is : ".$time-time();

 

Let me know what you get.

 

i tried that and i get this -1253024435 it doesn't even say the words  just -1253024435

 

 

still not working..  :confused:

<?php
session_start();
include("connect.php");
$username = $_SESSION['username'];
  mysql_connect("localhost", "ustackc1_Master", "KOWstHbK");
mysql_select_db("ustackc1_Ustack");
$result = mysql_fetch_assoc(mysql_query("SELECT * FROM Stacks WHERE username='$username'"))or die (mysql_error());
$user = $result['username'];
$time = $result['posted'];




if ((time() - $time < 50))

    {
  echo "<font color=white>You must wait 30 seconds between submits</font>";
}

else

{
echo "success";
}

Here is a troubleshooting hint: when a comparison fails, echo out the value(s) being used in the comparison so that you know exactly what it is.

 

Are you even sure that there is a row in Stacks for the username? Your code is not checking if the query worked or failed and that there is a row in the result set.

 

What do you get when you add the following two lines of code immediately after your first opening <?php tag -

 

ini_set("display_errors", "1");
error_reporting(E_ALL);

still get the same page

 

the query is working, there is a row in Stacks for that username..  each row has a timestamp

 

when i do this

 

echo "The value of my variable $time is : ".$time." The value of time() is : ".time()." The difference between the two is : ".$time-time();

 

it displays

"-1253026593"

 

it doesn't even show the text in the echo just "-1253026593"

 

when i echo $time i get this  2009-08-31 23:41:52

 

 

they are in two different formats?

 

 

 

 

 

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

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.