Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cannot pinpoint parse error 2

Status
Not open for further replies.

skibascott

IS-IT--Management
Mar 18, 2004
82
US
I am getting this error: Parse error: parse error in /export/home0/apache/htdocs/qalert.php(53) : eval()'d code on line 1

when running this code. I am assuming that it is referring to line 53, here is that block of code:
Code:
function array_csort() {  
	$args = func_get_args();
	$marray = array_shift($args);

  	$msortline = "return(array_multisort)";
   	foreach ($args as $arg) {
       $i++;
       if (is_string($arg)) {
          foreach ($marray as $row) {
               $sortarr[$i][] = $row[$arg];
           }
       } else {
          $sortarr[$i] = $arg;
      }
       $msortline .= "\$sortarr[".$i."],";
   	}

   	$msortline .= "\$marray));";
   	eval($msortline);
   	return $marray;
}

The research I have done on this error tells me that it some sort of syntax error. I am very new to php, so looking at this code with an untrained eye is not helping.
 
PHP's parse error on line xxx is normally not indicative of where the actual error lies.
Basically what I'm saying is :
complete code please.

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
I could be wrong, but I think this ones right there... you're evaling $msortline... so, perhaps you should start by outputing $msortline and realize the very first line is

Code:
return(array_multisort)

In which I immediately see two problems, no ending semicolon, and a call to a function with no ()'s and without its required argument list.

I didn't even bother to read the for loops once I noticed all you do is append to $msortline... but it's quite possible you have other problems in there...

Long and short of it... you need a
Code:
echo '<pre>'.$msortline.'</pre>';

Before your eval, and you need to make certain that what it outputs is valid php code.
 
is the error not coming from the eval() function ?. please display the string $msortline
 
$msortline string is this:
return(array_multisort)$sortarr[1],$sortarr[2],$sortarr[3],$sortarr[4],$sortarr[5],$marray));

I forgot to mention that line 53 is
Code:
eval($msortline);

Does this help?
 
Yes.
Code:
# wrong:
return(array_multisort)....
# right
return(array_multisort[b][COLOR=red]([/color][/b]
 
Great. That was the problem. Thank you all very much for the replies.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top