Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.