Jump to content

array value handling


brainstem

Recommended Posts

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;
?>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.