Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
lloydie-t
Forum Commoner
Posts: 88 Joined: Thu Jun 27, 2002 3:41 am
Location: UK
Post
by lloydie-t » Wed Nov 13, 2002 8:46 pm
I'm not that brilliant at MySQL, but i cannot work out why this string is causing an error. What I want to do is display user ID if the time is less than the time in a record.
Code: Select all
select user_id from sessions where SID = '65c55d073740a7b4b43e6f28d72922da' and time_expire<time()
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Thu Nov 14, 2002 2:04 am
What is the error you are getting?
Mac
cctrax
Forum Commoner
Posts: 36 Joined: Thu Jul 11, 2002 9:05 pm
Location: United States
Contact:
Post
by cctrax » Thu Nov 14, 2002 9:20 am
It would make our job a little easier if you posted the error
lloydie-t
Forum Commoner
Posts: 88 Joined: Thu Jun 27, 2002 3:41 am
Location: UK
Post
by lloydie-t » Thu Nov 14, 2002 10:08 am
How Dim am I. It turns out that the time I was using is Unix Time as set by PHP and not MySQL.
I am more or less sorted now except I think my code looks a bit sloppy because I do not know how to process the PHP time in an SQL query. Have a look, see what you think.
Code: Select all
<?php
<?php
$time_now = time();
$time_later = (time()+3600);
?>
<?php
$query = "select user_id from sessions where SID = '$SID' and user_type ='$user_type' and time_expire > $time_now";
$result = mysql_query($query) or die ("Error in query: $query " . mysql_error() );
$numrows =mysql_num_rows($result);
if($numrows >0)
{
$sql ="UPDATE sessions SET time_expire = '$time_later' WHERE SID = '$SID' ";
mysql_query($sql) or die('An error occured executing sql statement. SQL='.$sql.'<br>'.mysql_error());
}
else
{
echo "<meta http-equiv=refresh content='1;url=http://www.vvds/support/admin/alogin.php'>";
exit;
}
?>
?>