Re: Parse Error --- can not solve at this time... please assit
| From: | Minuk Choi | Date: | Mon, 11 Oct 2004 09:01:13 +0000 |
| Subject: | Re: Parse Error --- can not solve at this time... please assit | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-199156@lists.php.net to get a copy of this message | ||
the ", $desc)" is your culprit.
foreach ($arrayVariable as $key=>$value)
is probably the form you meant.
foreach ($admin_get_options_result as $api =>$file, $desc)
what is $api, $file, $desc supposed to be? If I were to hazard a guess, is the $admin... array a nested array, something like
$admin...[$api][$file]=$desc
NOTE : your name for $admin... is too long, so I'm writing it as "$admin..." in case you were wondering
If that is the case that you have a nested array, try the following
foreach ($admin... as $api => $data)
foreach ($data as $file=>$desc)
{
//stuff.} On a unrelated note, in your sniplet, there is no declaration for $admin_get_options_results, perhaps you meant, $admin_get_options_results_reference? Typically, I prefer to have short but meaningful variable names. Yours is kinda long. This is just a personal opinion, but perhaps you should reconsider your naming scheme, as that might save time on any misspelled variable names. HTH -Minuk ----- Original Message ----- From: "GH" <GaryHotko@gmail.com> To: "PHP General" <php-general@lists.php.net> Sent: Monday, October 11, 2004 1:48 AM Subject: [PHP] Parse Error --- can not solve at this time... please assit
With the following code, I am getting the following message.... Parse error: parse error, expecting `')'' in /var/www/html/cert/admin_template.php on line 30 Line 30 Reads as follows:foreach($admin_get_options_result as $api => $file, $desc)Can any one please assist. ***************ENTIRE CODE STARTING AT LINE 1 FOLLOWS ************* <html> <head> <title>ADMINISTRATION SCREEN</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?PHP require 'mod/db_access.php'; echo 'this is a test of the system'; if(!isset($_GET['api']) || (isset($_GET['api']) && ((strlen(trim(urldecode($_GET['api']))) == 0) || (!is_int($_GET['api']))))) $_GET['api']=0; if($_GET['api'] == 0) { $admin_get_options_query_text = "Select * from Adminpage"; $admin_get_options_results_reference = mysql_query($admin_get_options_query_text,$db_access) or die("Admin Get Options: ". mysql_error()); $admin_get_options_result = mysql_fetch_assoc($admin_get_options_result_reference); if(mysql_num_rows($admin_get_options_results_reference)>0) { ?> <table width="600"> <TR> <TD> Link </TD> <TD> DESCRIPTION </TD></TR> <?PHP foreach($admin_get_options_result as $api => $file, $desc) { echo '<TR> <TD>'; echo '<a href="#?api'.urlencoded($api).'"> Click Here </a> </td>'; echo '<TD>'.$desc.'</TD></TR>'; } ?> </table> <?PHP } } else { $admin_get_page_query_text = "Select * from Adminpage Where adminpageid = $_GET['api'] LIMIT 1"; $admin_get_page_results_reference = mysql_query($admin_get_page_query_text,$db_access) or die("Admin Get Page: ". mysql_error()); $admin_get_page_result = mysql_fetch_row($admin_get_page_result_reference); if (mysql_num_rows($admin_get_page_results_reference) > 0) { require "mod/admin/".trim(strtolower($admin_get_page_result[1])); } else { echo "ERROR: Invalid Admin Page Requested <br>"; echo 'Please Try Again ... <a href="admin_template.php?api=0"> Click Here </a>'; } } ?> </body> </html> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php