Jump to content

Parse error


Aces

Recommended Posts

Hi there..

 

I'm having problems with this error and can't seem to fix it I have looked over the coding for a while now and am stumped ???

 

Can anyone help plz?

 


<?

session_start();

include("gameconfig.php");

$title = "Doing crimes";

if(!$email || !$password){
error("field");
exit;
}

if($playerinfo[password] != $password){
error("password");
}else{
include("top.php");



$_GET['c']=abs((int) $_GET['c']);
if(!$_GET['c'])
{
print "Invalid crime";
}
else
{
$q=mysql_query("SELECT * FROM crimes WHERE crimeID={$_GET['c']}");
$r=mysql_fetch_array($q);
if($playerinfo['nerve'] < $r['crimeBRAVE'])
{
print "You do not have enough Brave to perform this crime.";
}
else
{
if($playerinfo['crimes'] > $r['crimePERCFORM']);
print "$r[crimeSTEXT]";
}
else
{
print "$r[crimeFTEXT]";
}
print "<br /><a href='docrime.php?c={$_GET['c']}'>Try Again</a><br />
<a href='crim.php'>Crimes</a>";
}
}


include("bottom.php");
}
?>

 

This is the error i get...

 

Parse error: syntax error, unexpected T_ELSE in /****/*******/************/*******.php on line 39

 

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/95639-parse-error/
Share on other sites

EDIT- you seem to have too many elses anyway... Try tabbing and spacing your code, this way you'll have a better chance to figure out where your logic went wrong

 

The elses are fine. I've tabbed it out. Here's his code.

<?php
session_start();
include("gameconfig.php");

$title = "Doing crimes";

if(!$email || !$password)
{
error("field");
exit;
}

if($playerinfo[password] != $password)
{
error("password");
}
else
{
include("top.php");

$_GET['c']=abs((int) $_GET['c']);
if(!$_GET['c'])
{
	print "Invalid crime";
}
else
{
	$q=mysql_query("SELECT * FROM crimes WHERE crimeID={$_GET['c']}");
	$r=mysql_fetch_array($q);
	if($playerinfo['nerve'] < $r['crimeBRAVE'])
	{
		print "You do not have enough Brave to perform this crime.";
	}
	else
	{
		if($playerinfo['crimes'] > $r['crimePERCFORM'])
		{
			print "$r[crimeSTEXT]";
		}
		else
		{
			print "$r[crimeFTEXT]";
		}
		print "<br /><a href='docrime.php?c={$_GET['c']}'>Try Again</a><br /><a href='crim.php'>Crimes</a>";
	}
}
include("bottom.php");
}
?>

 

Maybe part of the problem is this line?

$_GET['c']=abs((int) $_GET['c']);

Can you do that? Resave to the $_GET variable?

Link to comment
https://forums.phpfreaks.com/topic/95639-parse-error/#findComment-489648
Share on other sites

<?php session_start();

include("gameconfig.php");

$title = "Doing crimes";

if(!$email || !$password){
error("field");
exit;
}

if($playerinfo[password] != $password){
error("password");
}else{
include("top.php");
}

$_GET['c']=abs((int) $_GET['c']);

if(!$_GET['c'])
{
print "Invalid crime";
}

$q=mysql_query("SELECT * FROM crimes WHERE crimeID={$_GET['c']}");
$r=mysql_fetch_array($q);

if($playerinfo['nerve'] < $r['crimeBRAVE']) {
print "You do not have enough Brave to perform this crime.";
}elseif

($playerinfo['crimes'] > $r['crimePERCFORM']){
print $r['crimeSTEXT'];

}else{
print "$r[crimeFTEXT]";

print "<br /><a href='docrime.php?c={$_GET['c']}'>Try Again</a><br />
<a href='crim.php'>Crimes</a>";
}

include("bottom.php");

?>

Link to comment
https://forums.phpfreaks.com/topic/95639-parse-error/#findComment-489652
Share on other sites

The elses are fine. I've tabbed it out. Here's his code.

 

You've changed it. The problem was here:

 

else
{
if($playerinfo['crimes'] > $r['crimePERCFORM']);
print "$r[crimeSTEXT]";
}
else
{
print "$r[crimeFTEXT]";
}

 

As you can see, there's a else{}else{} structure.

 

@Aces - try using the code charlieholder posted or maybe redarrow's (I didn't go over that one).

 

Orio.

Link to comment
https://forums.phpfreaks.com/topic/95639-parse-error/#findComment-489655
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.