Re: timestamp



up2trouble wrote:
On May 14, 9:54 pm, Jerry Stuckle <jstuck...@xxxxxxxxxxxxx> wrote:
up2trouble wrote:
I changed it to bigint didn't see long one. Now it stores a 0. It
is not taking my value from mktime(). I read your suggested material.
I understood none of it.
Please learn how to reply properly. You were not responding to
yourself. Also, please quote the relevant parts (as in here).

As to your problem - you didn't give us enough information to go on -
like the real code you're using. Additionally, you need to determine
how you want the data stored - a unix timestamp works, but there are
valid reasons for using a datetime field, also (which is off topic in a
PHP newsgroup, and should be discussed in comp.databases.mysql).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@xxxxxxxxxxxxx
==================

I want a timestamp to store seconds and not a date/time format. The
only thing I took out of the code was the url for my page.

<?PHP
if(isset($_POST['printcodes']))
{
$gettime = date("Y-m-d H:i:s", mktime());
$sql= "SELECT * FROM $db_table10 WHERE created < $gettime";
$result = mysql_query ($sql, $connect) OR DIE ('Query 2 failed cause:
' . mysql_error());
$num = mysql_num_rows($result);

echo "<FIELDSET><FONT SIZE='+1' COLOR='#FF0000'>These are your codes.
Just save to your desktop, then
open in Word to print.</FONT></FIELDSET> ";

while ($row = mysql_fetch_array ($result))
{
echo "<P STYLE='text-align: justify; width: 550px;'>This is the
anonymous id code which will allow you to take your end of class
survey.
You will need a new code for each class. ";
echo "Go to xxxxxxxxxxxx. Then click on the Survey link.";
echo "Your case sensitive code is :<BR>";
echo "<FONT SIZE='+1'><STRONG>{$row['id']}</STRONG></FONT></P>";
}
}

?>

I should get a page of codes to print. It was working fine. However,
the problem is that when I need more codes I only want
the new ones to print out not the ones that have been already
printed. I thought that I could just set a time and say to print
codes that were generated at a time greater than the time entered.
Instead of codes, I get: Query 2 failed cause: You have an error in
your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near '18:47:17' at line 1.

When I create the code, I add in timestamp. I changed created to
entered and made varchar(25) in db. It doesn't keep a default value
and leaves what I entered in seconds.

$created = mktime();
$sql= "INSERT into $db_table10 (id, created) VALUES
('$random','$created')" ;





This was not the code in your first post - and you didn't have any code in your second one. That is why I asked.

Your query fails because a datetime value needs to be in single quotes in the query, i.e.

$sql= "SELECT * FROM $db_table10 WHERE created < '$gettime'";

And your other problems are SQL related - not PHP. I suggest you follow up in comp.lang.mysql - which is where you should be asking MySQL-related questions.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================

.



Relevant Pages

  • newbie :-sending variable value between two scripts...
    ... I am having some problems with my PHP and MySQL, basically, I need to ... #Enter Survey Author... ... #execute query ...
    (php.general)
  • Re: having problems with mySQL commands
    ... > enter the survey answers. ... > Query 6 failed because: You have an error in your SQL syntax; ... > the manual that corresponds to your MySQL server version for the right ...
    (comp.lang.php)
  • having problems with mySQL commands
    ... enter the survey answers. ... Query 6 failed because: You have an error in your SQL syntax; ... the manual that corresponds to your MySQL server version for the right ...
    (comp.lang.php)
  • Re: HP VMS web site: terrible coding of background colour
    ... I don't have PHP turned on right now but might have ... Yes having pop-ups turned off kills the survey. ... pop-ups, javascript and cookies ... The corporation went with client site metrics ...
    (comp.os.vms)
  • Re: Confused by mysqli
    ... When I started using MySQL with Perl back in 1998, ... fetch_assocon a query I prepared with bind variables, ... So I had it print out its eval string that it was trying to run. ... PHP will fail to run at all, because bind_result will not have enough ...
    (comp.lang.php)