2012-04-12 2 views
1

Bitte helfen Sie mir über das Problem im Titel angegeben.Warum dieser Hinweis (12-mal): Nicht initialisiert String-Offset: 0 in app_vsf.php on line 90

Der Codeabschnitt ist:

<?php 
// framework related things in this file. 

// vsf = Very Simple Framework 

$vsf = new stdClass; 

// default app_layout file 
$vsf->app_layout = 'app_layout.php'; 

// define the 'index' file, where we should link back to. 
// Need to include the path, otherwise S.E. friendly URLS get messed up. 
$vsf->self = '/mapcal/index.php'; 

// to support search engine friendly URLS, grab data from PATH_INFO 
if (isset($_SERVER["PATH_INFO"])) { 
$tmp_array = explode("/",$_SERVER["PATH_INFO"]); 

for ($index = 0; $index < count($tmp_array); $index++) { 
// only want the odd elements, they are the parameters. The even ones are the values 
if ($index % 2 == 0) { continue; } 
$_REQUEST[$tmp_array[$index]] = $tmp_array[$index+1]; 
} 
} 

// these functions are for form error handling 
$errorfields = array(); 

$errormsgs = array(); 

$errorwasthrown = FALSE; 

function adderrmsg($field = '', $msg = '') { 
global $errorfields; 
global $errormsgs; 
global $errorwasthrown; 

if ($field) { 
$errorfields[] = $field; 
} 
if ($msg) { 
$errormsgs[] = $msg; 
} 
$errorwasthrown = TRUE; 
} 

function displayformerrors($errhdr = 'The following errors occured:') { 
global $errorfields; 
global $errormsgs; 

if (empty($errorfields) and empty($errormsgs)) {return;} 

if (! empty($errormsgs)) { 
print "<p style='color: red;'>$errhdr<br>\n"; 

foreach ($errormsgs as $msg) { 
    print "&#8226; $msg<br>\n"; 
    } 
print "</p>\n\n"; 
} 
} 

function displayformlabel ($field = '', $label = '') { 
global $errorfields; 
if (in_array($field,$errorfields)) { 
print "<span style='color: red;'>$label</span>"; 
} 
else { 
print $label; 
} 
} 

function reuseform($formaction = 'new',$field_list = '',$query = '') { 
if ($formaction == "new") { 
foreach (split(",",$field_list) as $field) { 
    global ${$field}; 
    ${$field} = ''; 
    } 
} 
elseif ($formaction == 'form') { 
foreach (split(",",$field_list) as $field) { 
    global ${$field}; 
    ${$field} = $_REQUEST[$field]; 
    } 
} 

elseif ($formaction == 'query') { 
foreach (split(",",$field_list) as $field) { 
    global ${$field}; 
    ${$field} = $query[$field]; 
    } 
} 

} // close function reuseform 

?> 

Die Linie nicht 90 ist: $ {$ field} = $ query [$ Bereich];

Die Bekanntmachung wird 12 mal gezeigt, wie es 12 Felder in der Form sind, aber warum dies zeigt, und ich kann nicht die Daten in Formularfelder für die Bearbeitung Zweck sehen. Bitte helfen Sie mir in Bezug auf dieses Problem.

+0

Ich habe noch nie Gebrauch von '$ {$ var_name}' je in meinem kurzen Programmier Leben gesehen. – hjpotter92

+1

Variable Variablen ... –

+1

Scheint so, als ob wir vermissen, wo wiederverwendungsform aufgerufen wird. –

Antwort

0

Überprüfen Sie, ob $ _REQUEST die Variablen enthält.

Auch scheint reuseform $ query auf ‚auf‘ anstelle von Array() standardmäßig ... wird $ query richtig eingestellt werden? Dieser Fehler zeigt an, dass dies nicht der Fall ist.

0

Scheinbar ${$field} wertet "0" aus und $query["0"] ist nicht definiert.

0

können Sie diese schnelle Lösung verwenden, um mit isset

if(isset($GLOBALS[${$field}])) 
{ 
    ${$field} = $query [$field]; 
} 
+0

Vielen Dank Baba..der Hinweis Problem ist vorbei, aber die Feldwerte werden nicht angezeigt, sondern sie bleiben wie zuvor ausgeblendet. Würden Sie mir eine Lösung dafür geben? – rock

+0

das Skript Setzen Sie, wo Sie 'reuseform' Form fordern .. dann würde .. ich auf mehr Informationen haben, wie man am besten Sie dieses – Baba

+0

lösen kann ich meinen Beitrag bearbeiten für die Umsetzung des Skripts – rock

Verwandte Themen