473,388 Members | 1,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

unexpected $ (about 70 lines)

I get this error:
Parse error: parse error, unexpected $ in [file] on line 63
Where [file] is the path and filename for a file containing:
<?php
function cityname($style="10engdir eng 50engloc"){//creates name for city
return 'a city';
};

function powercentres($pop){//determines power centres for a city
return array(1=>array('name'=>'pc1','align'=>'true
neutral','views'=>array(1=>'self'),'type'=>'conven tional'));
$pcs=array();
if($pop<=80){
$roll=rand(1,20);
$align=rand(1,100);
if($align<=35){
$pcs[1]=array('align'=>'lawful good');
}elseif($align<=39){
$pcs[1]=array('align'=>'neutral good');
}elseif($align<=41){
$pcs[1]=array('align'=>'chaotic good');
}elseif($align<=61){
$pcs[1]=array('align'=>'lawful neutral');
}elseif($align<=63){
$pcs[1]=array('align'=>'true neutral');
}elseif($align<=64){
$pcs[1]=array('align'=>'chaotic neutral');
}elseif($align<=90){
$pcs[1]=array('align'=>'lawful evil');
}elseif($align<=98){
$pcs[1]=array('align'=>'neutral evil');
}else{
$pcs[1]=array('align'=>'chaotic evil');
}
if($roll-1<=13){
$pcs[1]['type']='conventional';
if(rand(1,20)==1){
}elseif($roll-1<=18){
$pcs[1]['type']='nonstandard';
}else{
$pcs[1]['type']='magical';
}
};

function npc($pop){//creates NPC population of city
return
array(1=>array('name'=>'npc1','lvl'=>array('ftr'=> 1),'race'=>'human','stats'=>array('int'=>10,'wis'= >10,'str'=>10,'dex'=>10,'cha'=>10,'con'=>10),'save s'=>array('f'=>2,'r'=>1,'w'=>1),'ac'=>10,'align'=> 'true
neutral','skills'=>20,'feats'=>2,'gear'=>'gear','s pells'=>''));
};

function sherrif($npcs){//chooses the sherrif
return 1;
};

function makecity($pop){//creates stats for 1 city
$city=array(
'name'=>cityname(),
'pop'=>$pop,
'urbanarea'=>($pop/38850),//38,850 people per square mile
'supportarea'=>($pop/180),//1 square mile can support 180 people
'powercentres'=>powercentres($pop),
'NPCs'=>npc($pop),
'fulltimeLEO'=>floor($pop/100),//1 LEO per 100 people (DMG)
'conscriptable'=>floor($pop/20)//1 conscriptable individual per 20 pop
(DMG)
);
$city['sherrif']=sherrif($city['NPCs']);
return($city);
}
?>

I know that some of the functions are returning before they do anything
(I'm going bugeyed and want to make sure the overall works). What's
this error from?

TIA,
RT
If you wanna email me, remove the "SPAM."
May 6 '06 #1
2 1104
Rik
RenTechie wrote:
I get this error:
Parse error: parse error, unexpected $ in [file] on line 63
Where [file] is the path and filename for a file containing:
<snip code>


Check your nesting, opening and closing {}, I don't think they're right.
Maybe it's disappeared in posting, but you function powercentres() doesn't
seems to close here.

Also, think about switch statements instead of elseif's.

Further
if($roll-1<=13){
$pcs[1]['type']='conventional';
if(rand(1,20)==1){ // do you have a particular use for a new rand()?
// you don't do anything here
}elseif($roll-1<=18){
$pcs[1]['type']='nonstandard';
}else{
$pcs[1]['type']='magical';
}
};

Reads as: $pcs[1]['type'] is 'conventional' is $roll < 14, if $roll is > 14
AND a new rand(1,20)==1, $pcs[1]['type'] doesn't get set at all!

Also: all the code in your powercentres() function doesn't get executed, as
the first thing you do is returning a statical array.

Proper tools for coding (syntax highlighting) and indenting code could have
told you a lot.

It's not pretty, no it sure ain't.
--
Rik Wasmus
May 6 '06 #2
Rik wrote:
RenTechie wrote:
I get this error:
Parse error: parse error, unexpected $ in [file] on line 63
Where [file] is the path and filename for a file containing:
<snip code>

Check your nesting, opening and closing {}, I don't think they're right.
Maybe it's disappeared in posting, but you function powercentres() doesn't
seems to close here.
Also, think about switch statements instead of elseif's.
Reads as: $pcs[1]['type'] is 'conventional' is $roll < 14, if $roll is > 14
AND a new rand(1,20)==1, $pcs[1]['type'] doesn't get set at all!
Also: all the code in your powercentres() function doesn't get executed, as
the first thing you do is returning a statical array.
Proper tools for coding (syntax highlighting) and indenting code could have
told you a lot.
It's not pretty, no it sure ain't.


It was a couple of unclosed blocks right where you pointed. I wanted to
test the bigger function, and was returning static results to make sure
that the structure came through. The bad indentations were because I
went back and was adding stuff and decided to test.

Thanks for the help,
RT
May 6 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tony Gahlinger | last post by:
I'm learning/experimenting with some simple JS/html markup, running an apache daemon and mozilla firefox browser in RH 9. Let's say I run the following markup with one or more of lines 6-10...
13
by: Nigel J. Andrews | last post by:
This will be a little vague, it was last night and I can't now do the test in that db (see below) so can't give the exact wording. I seem to remember a report a little while ago about tsearch v2...
3
by: Fred Nelson | last post by:
Hi: I'm a VB.NET web programmer who is writing my first C# web application! I'm having a problem trapping and logging unexpected errors. In my VB.NET applications I have a routine called by...
1
by: Ben | last post by:
Hi All, Have you ever experience the situation when designing a WebForm: Switching between "Design" and "HTML" view sometime and you get an error message about Internet Explore, then the...
8
by: vagos | last post by:
Can someone please tell me why i get the following error ?? The strange is that sometimes i get the error and sometimes not !! Also there is no syntax error on line 251 Warning: Unexpected...
5
by: Vijayakrishna Pondala | last post by:
Hi, We are using the following error randomly, when accessing a webservice method/servlet hosted on JBoss application server: The underlying connection was closed: An unexpected error occurred...
8
by: Jim Michaels | last post by:
C:\prj\quiz\withusers>php tareports.php PHP Parse error: syntax error, unexpected T_ELSE in C:\prj\quiz\withusers\tareports.php on line 205 this is the section of code. if (isset($row4)) {...
3
by: Anup Daware | last post by:
Hi Group, I am facing a strange problem here: I am trying to read xml response from a servlet using XmlTextWriter. I am able to read the read half of the xml and suddenly an exception:...
1
epots9
by: epots9 | last post by:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /var/www/html/xxx.php on line xxx I get that message when i try to run my...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.