major parse error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

major parse error

Post by m3rajk »

this one leaves me clueless. i've checked. all functions are closed yada-yada... i can't find ANY $ with nothing immediately following...note, the error is on the line with the closing ?> for the page.
Parse error: parse error, unexpected $ in /var/www/html/findyourdesire/admin.php on line 1611
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

might be an unbalanced bracket or similar

Code: Select all

<?php
function func()
&#123;

?>
PHP Parse error: parse error, unexpected $end in test.php on line 5

Code: Select all

<?php
print("something
?>
PHP Parse error: parse error, unexpected $end in test.php on line 3
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

lol. a friend just pointed out i have the same comment on two if statements one openint the function and one for verification. changing the comment allowed me to see that was the case. the duplicate comment made me think otherwise
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

ok. riddle me this. riddle me that. why the hell is tha acces not printing out? the $sa i have is contained in BOTH arrays, and the testing printout proves it's in the first one, yet the echo for $sa yeilds nothing while it's sucessfully picing up the last three if statements

Code: Select all

function choice($db){ # main admin page
  include("/home/joshua/includes/fyd.altincs.php"); # includes file (precautionary measure)
  $un=$_COOKIE['un']; $options='';
  /* find access level in db. set appropriately */
  $accessret=mysql_query("SELECT site_access FROM users WHERE username='$un' AND password='$pw'", $db);
  $access=mysql_fetch_array($accessret); 
  $sa=$access['site_access'];
  echo $sa;
  echo "<br />";
  foreach($approvers as $apps){ echo "$apps, "; }
  if(contains($sa, $approvers)){ # add the approver options
    echo "adding approve";
    $options.="   <option value="appbio">Approve Bios</option>\n        <option value="appmain">Approve Main Pictures</o
ption>\n          <option value="appt1">Approve 1st Thumb</option>\n    <option value="appt2">Approve 2nd Thumb</option>
\n        <option value="appt3">Approve 3rd Thumb</option>\n    <option value="appt4">Approve 4th Thumb</option>\n    <o
ption value="appsalute">Approve Salute Picture</option>\n"; }
  if(contains($sa, $suspenders)){ # add the suspend options
    echo "adding suspend";
    $options.="   <option value="susus">Suspend User</option>\n"; }
  if(($sa==$jra)||($sa==$adm)||($sa==$web)){ # add things for jr/full admins
    $options=$options."   <option value="susrev">Review Suspended Users</option>\n      <option value="access">Adjust Us
er Access</option>\n"; }
  if(($sa==$adm)||($sa==$web)){ # full admin options
    $options.="   <option value="delu">Delete User</option>\n   <option value="adjfor">Adjust Forums</option>\n"; }
  if($sa==$web){ # only the webmaster, since the full admins might not have the db knowledge
    $options.="   <option value="misc">Misc Commands</option>"; }
    
    echo <<<END
      <h3>Welcome to the Admin Choice Page. If you link a non-admin to any admin page, they will see nothing, except for the
 an error message letting them to know to report it. (security)</h3>
      <p>
        <!-- php checks access level in form creation & makes select choices based on it -->
        <form action="$_SERVER[PHP_SELF]" target="_blank" method="POST" >
        <select name="fn" size="1">
$options
        </select>
        <input type="submit" value="Administrate!">
        </form>
      </p>
    </center>
  </body>
</html>
END;
}
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Where do variables such as $web and $adm come from? Is your error reporting set to E_ALL? Please, please, please, format and space your code so that it's easy to follow and avoid putting two statements on one line. If you're using heredoc format in one place, why not use it on all those <option> tags so that you get all the line breaks and tabbing without worrying about \n and having to escape double quotes.

Code: Select all

<?php

# main admin page
function choice($db)
{ 
	# includes file (precautionary measure)
	include('/home/joshua/includes/fyd.altincs.php'); 

	$un      = $_COOKIE['un'];
	$options = '';

	/* find access level in db. set appropriately */
	$sql       = "SELECT site_access FROM users WHERE username='$un' AND password='$pw'";
	$accessret = mysql_query($sql, $db) or die(mysql_error().'<p>'.$sql.'</p>');

	// are you sure that there will be a record returned?
	$access    = mysql_fetch_array($accessret);
	$sa        = $access['site_access'];

	echo $sa;
	echo '<br />';
	
	foreach ($approvers as $apps) {
		echo $apps.', ';
	}
	
	# add the approver options
	if (contains($sa, $approvers)) { 
		echo 'adding approve';
		$options =<<<END
		
	<option value="appbio">Approve Bios</option>
	<option value="appmain">Approve Main Pictures</option>
	<option value="appt1">Approve 1st Thumb</option>
	<option value="appt2">Approve 2nd Thumb</option>
	<option value="appt3">Approve 3rd Thumb</option>
	<option value="appt4">Approve 4th Thumb</option>
	<option value="appsalute">Approve Salute Picture</option>
END;
	}
	
	# add the suspend options
	if (contains($sa, $suspenders)) {
		echo 'adding suspend';
		
		$options .=<<<END
	
	<option value="susus">Suspend User</option>
END;
	}

	# add things for jr/full admins
	if (($sa == $jra) || ($sa == $adm) || ($sa == $web)) { 
		$options .= <<<END

	<option value="susrev">Review Suspended Users</option>
	<option value="access">Adjust User Access</option>
END;
	}

	# full admin options
	if (($sa == $adm) || ($sa == $web)) { 
		$options .=<<<END
		
	<option value="delu">Delete User</option>
	<option value="adjfor">Adjust Forums</option>
END;
	}

	# only the webmaster, since the full admins might not have the db knowledge
	if ($sa == $web) { 
		$options .= <<<END

	<option value="misc">Misc Commands</option>
END;
	}

echo <<<END
<h3>Welcome to the Admin Choice Page. If you link a non-admin to any admin page, they will see nothing, except for the
an error message letting them to know to report it. (security)</h3>

<!-- php checks access level in form creation & makes select choices based on it -->
<form action="$_SERVER[PHP_SELF]" target="_blank" method="POST" style="margin: 15px 0;">
	<select name="fn" size="1">
	$options
	</select>
	<input type="submit" value="Administrate!" />
</form>

</center>
</body>
</html>
END;
}


?>
Mac
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

any variable not explicitly defined in that function is in the includes. and there has to be a record that will be returned... because otherwise they wouldn't have been able to get the page
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

m3rajk wrote:any variable not explicitly defined in that function is in the includes
It really does help us to debug if we know these things.
m3rajk wrote:and there has to be a record that will be returned... because otherwise they wouldn't have been able to get the page
But when you do

Code: Select all

echo $sa;
you get nothing? $un comes from a cookie, where does $pw come from?

Mac
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

$un and $pw are suppossed to be in cookies. i shouldn't be getting anything. if that's not set.
ummm.. looks like i have another error to hunt down, what;s the typo between $web and what i named what that should be in the included file.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

If $pw is supposed to be coming from a cookie, then you need to add a line similar to:

Code: Select all

$un = $_COOKIE['un'];
to retrieve that data. Do you have error_reporting set to E_ALL? If not put

Code: Select all

error_reporting(E_ALL);
at the top of the script to help you debug. You'll then get undefined variable warnings if you don't set a variable and try and access it.

Mac
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

ok. i'll try setting the error reporting to E_ALL before i ask on why this thing that is giving me trouble witht he function... maybe that will help me solve it on my own

it was E_ALL & ~E_NOTICE
i changed it to E_ALL
Post Reply