Jump to content


Photo

array value handling


  • Please log in to reply
1 reply to this topic

#1 brainstem

brainstem
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 26 September 2006 - 03:17 PM

Here is my issue (I am still green, be nice);
Trying to pull values from 2 arrays based on error or changed state, i.e you just logged in, you didn't fill a form right, etc...
This is going to be implimented accoss a large site with multiple dir levels so i wanted an include to handle arrays where all of the errorlevel and messagelevel information was and thier corresponding links.

The issue i'm having is, I have accomplished this with 'list' but its very cumbersome and I know there is a way to compact it down to a simple $array[0] type call but i cant get it to work.
here is my code, plz help. The error i am currently getting is 'Unexpected ['.
thanks in advance.

call_defs.php ~
<?php
$statei = array(0=>'Error(s) Found.',1=>'Success!',2=>'Logging In '.$user.'.',3=>'Logging Out '.$user.'.',4=>'Welcome Administrator');
$linki = array(0=>'javascript:history.back()',1=>'console.php',2=>'login.php',3=>'../index.php');

?>

index.php ~
<?php
...

if ($err<>null) {
include ("call_defs.php");
$state = &statei[0]; //FAILING ON THIS LINE 'Unexpected ['
$linkstate = &linki[0];
include ("call_state.php");
echo ("<META HTTP-EQUIV=Refresh CONTENT=\"5; URL=javascript:history.back(-1)\">");
exit();
...
?>

call_state.php ~
<?php
echo <<<html
... // in a table blah blah blah
$state //echos errorlevel
$linkstate //echos appropriate link in case browser doesn't support refresh.
...
html;
?>


#2 brainstem

brainstem
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 26 September 2006 - 03:29 PM

onlamp is now on my php blacklist.
A help reference on getting values out of arrays told me to use & instead of $ when calling directly to an array value.
basterds.
thanks anyway
s-





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users