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