PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Mon Dec 09, 2019 11:34 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Offset problem
PostPosted: Thu Oct 20, 2005 1:01 am 
Offline
Forum Regular

Joined: Fri Jun 10, 2005 1:43 am
Posts: 592
Location: LT


Last edited by Ree on Thu Oct 20, 2005 6:26 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 20, 2005 1:24 am 
Offline
Neighborhood Spidermoddy
User avatar

Joined: Mon Mar 29, 2004 4:24 pm
Posts: 31559
Location: Bothell, Washington, USA


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 20, 2005 1:34 am 
Offline
Forum Regular

Joined: Fri Jun 10, 2005 1:43 am
Posts: 592
Location: LT


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 20, 2005 5:01 am 
Offline
Jedi Mod
User avatar

Joined: Tue Dec 21, 2004 6:03 pm
Posts: 5263
Location: usrlab.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 20, 2005 6:01 am 
Offline
Forum Regular

Joined: Fri Jun 10, 2005 1:43 am
Posts: 592
Location: LT


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 20, 2005 6:12 am 
Offline
Forum Regular

Joined: Thu Apr 24, 2003 6:51 am
Posts: 416
Location: The Netherlands
Looking at your error: Uninitialized string offset: 0 ....

I think he try'ing to do : $_SESSION['msg'] = $msg[0];

So $authorization->getError() return's 0?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 20, 2005 6:13 am 
Offline
Forum Regular

Joined: Fri Jun 10, 2005 1:43 am
Posts: 592
Location: LT
No, as I mentioned above $authorization->getError() IS 'InvalidLogin', I echoed it:
Syntax: [ Download ] [ Hide ]
if ($authorization->error())

{

  echo $authorization->getError(); //Outputs 'InvalidLogin'

  $_SESSION['msg'] = $msg[$authorization->getError()]; //The prob here

  include('pages/index.php');

  exit;

}

I even tried this:
Syntax: [ Download ] [ Hide ]
if ($authorization->error())

{

  $err_id = $authorization->getError();

  echo $err_id; //Outputs 'InvalidLogin'

  $_SESSION['msg'] = $msg[$err_id]; //The prob still there

  include('pages/index.php');

  exit;

}

I have NO clue what is wrong...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 20, 2005 8:29 am 
Offline
Neighborhood Spidermoddy
User avatar

Joined: Mon Mar 29, 2004 4:24 pm
Posts: 31559
Location: Bothell, Washington, USA


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 20, 2005 9:03 am 
Offline
Forum Regular

Joined: Fri Jun 10, 2005 1:43 am
Posts: 592
Location: LT
In my first post, the POST of the form goes to the script itself, that is, to index.php

Here's something I tried for testing, pretty much the same situation as in my first post (the POST goes to the script itself).

test.php
Syntax: [ Download ] [ Hide ]
<?php

session_start();

ini_set('display_errors', 1);

error_reporting(E_ALL);

?>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

</head>

<body>

<?php



include('lib/class.Tester.php');

include('lang/back_EN.php');



$_SESSION['msg'] = '';



if (!isset($_POST['sub']))

{

  include('pages/test.php');

  exit;

}



$tester = &new Tester();

$tester->setError('InvalidLogin');



if ($tester->error())

{

  $_SESSION['msg'] = $msg[$tester->getError()];

  include('pages/test.php');

}



?>

</body>

</html>

lang/back_EN.php
Syntax: [ Download ] [ Hide ]
<?php



//class.Database.php

$msg['NoDB'] = 'Unable to connect to database.';



//class.Authorization.php

$msg['InvalidLogin'] = 'Invalid username or password.';



//class.Validator.php

$msg['EmptyField'] = '<b>{field}</b> field is empty.';

$msg['InvalidField'] = '<b>{field}</b> field is invalid.';



/* ... */



?>

lib/class.Tester.php
Syntax: [ Download ] [ Hide ]
<?php



class Tester

{

  var $error;



  function Tester()

  {

    $this->error = '';

  }



  function setError($error)

  {

    $this->error = $error;

  }



  function getError()

  {

    return $this->error;

  }



  function error()

  {

    return (bool)$this->error;

  }

}



?>

pages/test.php
Syntax: [ Download ] [ Hide ]
<br />

<br />

<br />

<?php

echo $_SESSION['msg'];

$_SESSION['msg'] = '';

?>

<br />

<br />

<form method="post" action="test.php">

  <table>

    <tr>

      <td><input type="submit" value="Submit" name="sub" /></td>

    </tr>

  </table>

</form>

On my local machine, I do get the message ('Invalid username or password.'), on the host I get the same uninitialized offset error. Maybe you will be able to spot the problem (if the code has a flaw).

Also, you can check the problem live at http://test.keliozenklai.lt/test2/test.php . It uses exactly the same code as in this post.


Last edited by Ree on Thu Oct 20, 2005 11:52 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 20, 2005 10:57 am 
Offline
Forum Regular

Joined: Fri Jun 10, 2005 1:43 am
Posts: 592
Location: LT


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 16, 2005 2:00 pm 
Offline
Forum Contributor

Joined: Wed Jan 14, 2004 11:21 am
Posts: 313
Location: planet earth


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group