Thanks alot for your reply :) I really appreciate your help..

Upto now I made this script :

<?php

include("Config.php");

$link = mysql_connect("$user_hostname", "$user_username", "$user_password");
mysql_select_db("$user_database", $link);

$UserName = $_GET['UserName'];
$Password = $_GET['Password'];
$LogoutTime = date("U");

$query1 = "UPDATE accounts SET LogoutTime=$LogoutTime";
$result1 = mysql_query($query1) or die("Query error: " . mysql_error());
$query2 = "SELECT LoginTime,Distance,LessonNumber FROM accounts WHERE
UserName='$UserName' AND Password='$Password'";
$result2 = mysql_query($query2) or die("Query error: " . mysql_error());
$row2 = mysql_fetch_row($result2);
$query3 = "UPDATE accounts SET LessonNumber=LessonNumber + 1";
$RightLoginTime = $row2["LoginTime"];
$Distance = $row2["Distance"];
$LessonNumber = $row2["LessonNumber"];
$LessonsTimeLimit = "30";


?> <pre> <?
echo $query1;
echo $query2;
echo $query3;
?> </pre> <?



$query4 = "UPDATE accounts SET Distance='$LogoutTime - $RightLoginTime'
WHERE UserName='$UserName' AND Password='$Password'";
$result4 = mysql_query($query4) or die("Query error: " . mysql_error());
?> <pre> <?
echo $query4;
?> </pre> <?


if($Distance == $LessonsTimeLimit){
    $result3 = mysql_query($query3) or die("Query error: " . mysql_error());

}else{
    echo "Not yet!";
}

?>


It update everyting fine.. but the problem is that the "LoginTime" value is
not imported from the database!

So what is the problem?

Regards..
----- Original Message -----
From: "David OBrien" <[EMAIL PROTECTED]>
To: "Radwan Aladdin" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Thursday, January 29, 2004 12:07 AM
Subject: Re: [PHP] Still error messages!!


> At 02:45 PM 1/28/2004, Radwan Aladdin wrote:
> >Now I fixed the error message.. but the problem is in "Distance = 0"
> >always.. because the LoginTime is a string.. I fetch it but the same
thing!!
> >
> >This is the new script :
> >
> ><?php
> >
> >phpinfo();
> >include("Config.php");
> >
> >$link = mysql_connect("$user_hostname", "$user_username",
"$user_password");
> >mysql_select_db("$user_database", $link);
> >
> >$UserName = $_GET['UserName'];
> >$Password = $_GET['Password'];
> >$LogoutTime = date("U");
> >
> >$query1 = "UPDATE accounts SET LogoutTime=$LogoutTime";
>
> You are not executing this query anywhere in the script
>
> >$query2 = "SELECT LoginTime,Distance,LessonNumber FROM accounts WHERE
> >UserName='$UserName' AND Password='$Password'";
> >$result2 = mysql_query($query2) or die("Query error: " . mysql_error());
> >$row2 = mysql_fetch_row($result2);
>
> Great that you used this to get the results in a row but you need to
> reference the row in your script
>
> >$query3 = "UPDATE accounts SET LessonNumber=LessonNumber + 1";
>
> Instead of
>
> >$RightLoginTime = 'LoginTime';
> use
> $RightLoginTime = $row2["LoginTime"];
>
> but you need to do a mysql_query for the $query1 and get that value frst
>
> Instead of
>
> >$Distance = 'Distance';
> use
> $Distance = $row2["Distance"];
>
> Instead of
>
> >$LessonNumber = 'LessonNumber';
> use
> $LessonNumber = $row2["LessonNumber"];
>
> The user comments on the online manual are a very good starting
> point for basic programming steps needed to accomplish a task
> If  you would have taken the example on that page you would have
> seen the steps needed:
>
> set your query string
> execute the query
> get the resultset into a variable
>
> This is the norm for all mysql php programming just putting a
> $Distance='Distance'
> does not tell php that what you really want it do read the database and
> place the value of
> Distance into $Distance
>
> -Dave
>
> >$LessonsTimeLimit = "30";
> >
> >
> >?> <pre> <?
> >echo $query1;
> >echo $query2;
> >echo $query3;
> >?> </pre> <?
> >
> >
> >
> >$query4 = "UPDATE accounts SET Distance=" . $LogoutTime - $RightLoginTime
.
> >" - LoginTime WHERE UserName=" . $UserName . " AND Password=" . $Password
.
> >")";
> >$result4 = mysql_query($query4) or die("Query error: " . mysql_error());
> >$row4 = mysql_fetch_row($result4);
> >?> <pre> <?
> >echo $query4;
> >?> </pre> <?
> >
> >
> >if($Distance == $LessonsTimeLimit){
> >     $result3 = mysql_query($query3) or die("Query error: " .
mysql_error());
> >
> >}else{
> >     echo "Not yet!";
> >}
> >
> >?>
> >
> >So why it is making the Distance value = 0 and it doen't update the value
in
> >the database. (Because it must update the value in the database by it)
> >
> >Regards..
> >----- Original Message -----
> >From: "John Nichel" <[EMAIL PROTECTED]>
> >To: "Radwan Aladdin" <[EMAIL PROTECTED]>
> >Cc: <[EMAIL PROTECTED]>
> >Sent: Wednesday, January 28, 2004 11:37 PM
> >Subject: Re: [PHP] Still error messages!!
> >
> >
> > > Radwan Aladdin wrote:
> > > <snip>
> > > > So where are the errors?
> > > >
> > > > Waiting your help please..
> > > >
> > > > Regards..
> > > >
> > >
> > > What's the error message???
> > >
> > > --
> > > By-Tor.com
> > > It's all about the Rush
> > > http://www.by-tor.com
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> >
> >--
> >PHP General Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Reply via email to