PHP zeigt Fehler obwohl keiner da

Servus,
mir wird ein Fehler gezeigt, obwohl keiner existiert:
Parse error: syntax error, unexpected T_VARIABLE in […]/cmbox.func.php on line 118

mein code:

function getLoggedInUser($users){ //Zeile 96
/\*
Für Lösung unbedeutender Kommentar =\> [...]
\*/
 $user = '';
 if(isset($\_SESSION['user'])){
 for($LIUa=0; $LIUa user); $LIUa++){
 if(strval($\_SESSION['user']) == strval(sha1(strval($users-\>user[$LIUa]-\>name)))){
 $user = strval($users-\>user[$LIUa]-\>name);
 }
 }
 }
 return $user; //Zeile 118
}

Bei $users handelt es sich um ein SimpleXMLElement.

MAche ich was falsch?

grtz
michi

In diesem Stück ist kein Fehler. Der muss also in dem Code sein, den du nicht gepostet hast…

ja aber laut fehler ist der aber da. egal, komplette datei:

function getURL(){
 $rtn = 'http://'. $\_SERVER['SERVER\_NAME'] . $\_SERVER['PHP\_SELF'];
 if(count($\_GET) \> 0){ 
 $rtn .= "?";
 foreach($\_GET as $key=\>$value){
 $rtn .= $key."=".$value.'&';
 } 
 }
 $rtn = (substr($rtn,-1) == '&' ? substr($rtn,0,-1) : $rtn);
 return $rtn;
}
function getHighestModuleId($fill = false,$modules = ""){
 if($modules == "")
 $modules = $GLOBALS['modules'];
 $id = 0;
 $foundfreeplace = false;
 for($i = 0; $i content); $i++){
 if($id content[$i]-\>id)){
 if($fill == true){
 if($foundfreeplace == false)
 $id = intval($modules-\>content[$i]-\>id);
 } else
 $id = intval($modules-\>content[$i]-\>id);
 }
 }
 return $id;
}
function createNewModule($fill = false,$modules = ""){
 if($modules == "")
 $modules = $GLOBALS['modules'];
 $id = 0;
 $foundfreeplace = false;
 for($i = 0; $i content); $i++){
 if($id content[$i]-\>id)){
 if($fill == true){
 if($foundfreeplace == false)
 $id = intval($modules-\>content[$i]-\>id)+1;
 } else
 $id = intval($modules-\>content[$i]-\>id)+1;
 }
 }
 $xml = $modules-\>addChild('content');
 $xml-\>addChild('id',strval($id));
 $xml-\>addChild('title','');
 $xml-\>addChild('html','');
 $xml-\>addChild('type','text');
 file\_put\_contents('db/modules.xml',$GLOBALS['db']-\>Encrypt($modules-\>asXML()));
}

function setParam($param,$value,$url = ""){
/\*intval($modules-\>content[$i]-\>id)
Defintion: 
setGETParams(String $param, String $value [, String $url])

Sets an GET-Parameter for the givven URL ($url). $param is the
parameter-name and $value the value. The function can be used to
change the value for the parameter or to add the parameter 
including the value. $param will always converted to lowercase.
Can be used for EVERY url, if ? is not present, it'll be added.
If $url is not specified, the actual url (getURL():wink: will be used.
If $value is an empty string, the parameter $param will be deleted
including the value.
Other Parameters than the givven will not be modified. 

Returns an String with the givven parameters

NOT SECURED AGAINST:
runtime errors
\*/
 $url = (strval($url) == "" ? getURL() : strval($url));
 $uurl = (strval($url) == "" ? getURL() : strval($url));
 $url = (strpos($url,'?') != false ? substr($url,strpos($url,'?')+1) : "");
 $oldparams = explode('&',$url);
 $found = false;
 $newparams = array();
 foreach($oldparams as $p){
 if($p != ""){
 $pc = explode('=',$p);
 $newparams[strtolower($pc[0])] = $pc[1];
 }
 }
 $newparams[strtolower(strval($param))] = strval($value);
 $rtn = str\_replace('?'.$url,'',$uurl);
 $rtn .= '?';
 foreach($newparams as $p=\>$v){
 if($v != "")
 $rtn .= $p.'='.$v.'&';
 }
 $rtn = substr($rtn,0,-1); 
 return $rtn;
}

function getLoggedInUser($users){
/\*
Defintion: 
getLoggedInUser(SimpleXMLElement $users)

Gets the actual logged-in users by hash-checking. The hash will got from $\_SESSION['user'].

Returns if
... the user was identified, the username
... the user was not found or no one is logged in, an empty string

NOT SECURED AGAINST:
SimpleXML errors, runtime errors
\*/
 $user = '';
 if(isset($\_SESSION['user'])){
 for($LIUa=0; $LIUa user); $LIUa++){
 if(strval($\_SESSION['user']) == strval(sha1(strval($users-\>user[$LIUa]-\>name)))){
 $user = strval($users-\>user[$LIUa]-\>name);
 }
 }
 }
 return $user;
}



function getPageNo($id,$pages = $GLOBAL['pages']){

 $rtn = -1;

 for($PNa=0; $PNapage); $PNa++){

 if(intval($pages-\>page[$PNa]-\>id) == intval($id))

 $rtn = $PNa;

 }

 return $rtn;

}



function getModuleNo($id,$modules){

 $rtn = -1;
 for($PNa=0; $PNacontent); $PNa++){
 if(intval($modules-\>content[$PNa]-\>id) == intval($id))

 $rtn = $PNa;

 }

 return $rtn;

}



function getUserRights($userno,$users){
/\*
Defintion: 
getUserRights(Int $userno, SipleXMLElement $users)

Gets the Rights of the User with the givven index ($userno). Including assigned groups. 

Returns if
... the user was found, all rights as an Array with String-elements
... the user was not found, an empty Array

NOT SECURED AGAINST:
Type errors, SimpleXML errors, runtime errors
\*/

 $rights[] = array();

 $rights = explode(' ',strval($users-\>user[$userno]-\>rights));

 if($users-\>user[$userno]-\>group != ''){

 $u\_group = explode(' ',$users-\>user[$userno]-\>groups);

 for($b=0; $b group as $xug){

 if($xug-\>name == $u\_group){

 $ugr = explode(' ',$xug-\>rights);

 foreach($ugr as $right)

 $rights[] = $right;

 }

 }

 }

 }

 return $rights;

}

function getUserNo($username,$users,$strict = false){

/\*
Defintion: 
getUserNo(String $username, SipleXMLElement $users[, boolean $strict])

Gets the actual element-index for the givven Username ($username).
$strict ist normally false, set it to true, if you want a case-sesetive
search. $users is the SimpleXMLElement for the UserXML, the haystack.

Returns if
... the user was found, the index (int) of the -Element in $users
... the user was not found -1 (int)

NOT SECURED AGAINST:
Type errors, SimpleXML errors, runtime errors
\*/ 
 $user = -1;
 $username = ($strict ? $username : strtolower($username));

 for($UNa=0; $UNa user); $UNa++){
 $actual\_user = ($strict ? strval($users-\>user[$UNa]-\>name) : strtolower(strval($users-\>user[$UNa]-\>name)));
 if($actual\_user == $username){

 $user = $UNa;

 }

 }

 return $user;

}

?\>

Hi,

Bei mir zeigt der den da an:

function getPageNo($id,$pages = $GLOBAL[‚pages‘]){

was deiner Initialisierung liegt.
http://de3.php.net/manual/de/functions.arguments.php :
"Der Vorgabewert muss ein konstanter Ausdruck sein, darf also zum Beispiel keine Variable, Eigenschaft einer Klasse oder ein Funktionsaufruf sein. "

Also weise da NULL zu und schaue später nach, obs NULL ist und weise dann in der Funktion das $GLOBAL[‚pages‘] zu…

Alexander

$rtn = -1;

for($PNa=0; $PNapage); $PNa++){

1 Like

Problem gelöst! Danke an alle!