Re: [PHP-DB] Session start

2010-05-14 Thread Luiz Alberto
Barry,

Did you try to use setcookie with expiry date in the past? You could
use 
setcookie before header function of the following manner.

session_start();
if (!(isset($_SESSION['username']) && $_SESSION['username'] != '')) {
setcookie("session","session id", 1);
header ("Location: login.html");
}

Best regards,
Luiz Alberto



On Fri, 2010-05-14 at 17:47 +0100, Barry Zimmerman wrote:

> I have a problem with my system, not sure how I can fix this one. A user has
> a log in page and takes them to different pages, now each of these pages has
> a check to make sure they are logged in with the following code:
> 
> session_start();
> if (!(isset($_SESSION['username']) && $_SESSION['username'] != '')) {
> header ("Location: login.html");
> exit;
> }
> 
> So if they are not logged in it redirects them to the log in page. No
> problems there.
> 
> Now if a user is not logged in and comes back to that page, it starts the
> session so giving them a session id and redirects them back to thge login
> page. The problem I have is I do NOT want the session to start, I need them
> to hit the log in page with no sessions there. I have tried all sorts but
> just cannot get this to work.
> 
> I have tried adding this to the code.
> 
> session_start();
> if (!(isset($_SESSION['username']) && $_SESSION['username'] != '')) {
> *session_destroy();*
> header ("Location: login.html");
> exit;
> }
> 
> But that did not work? Please I am stuck for ideas?


Re: [PHP-DB]how to handle exception in php

2010-05-02 Thread Luiz Alberto
Dear Bavithra,

I would suggest you the following solution 

$sql = "SELECT x FROM y";
$rs  = mysql_query ($sql)
$num = mysql_numrows($rs);
while ($i < $num){
z = mysql_result($rs, $i, 'x');
$i++;
}

I hope that above solution  help you.

Luiz Alberto


On Sun, 2010-05-02 at 10:56 +0530, Bavithra R wrote:
> hi friends
> 
> I am doing a simple student mark details project.
> for calculating rank I need to compare the total marks one by one.
> To do so i use *for loop.* so atlast while reaching the end of the table it
> shows the following warning.
> *
> Warning*: mysql_result()
> [function.mysql-result<http://127.0.0.1/pro/function.mysql-result>]:
> Unable to jump to row 18 on MySQL result index on line *50*
> 
> It is because it has no next value to compare.How to use try..catch
> exception handling in this.?Or any other suggestion.
> Can anybody help me
> 
> --Bavithra


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php