User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 392,048 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,339 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 136 | Replies: 5
Reply
Join Date: Mar 2007
Location: GA
Posts: 27
Reputation: blufab is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
blufab blufab is offline Offline
Light Poster

creating arrays

  #1  
29 Days Ago
I am trying to understand why i am getting the following error:
PHP Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in C:\Registration.class.php on line 43

    var $team1;
    var $team2;
    var $team3;
    var $team4;
    var $team5;
    var $team6;
    var $team7;
    var $team8;
    var $team9;
    var $team10;
    var $team11;
    var $team12;
    var $team13;
    var $team14;
    var $team15;
    var $team16;
...
43: $teamMbrs= array($team1, $team2, $team3, $team4, $team5, $team6, $team7, $team8, $team9, $team10, $team11, $team12, $team13, $team14, $team15, $team16);

all of the variables being stored in the array are predefined.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2007
Location: Arkansas
Posts: 348
Reputation: buddylee17 will become famous soon enough buddylee17 will become famous soon enough 
Rep Power: 2
Solved Threads: 68
buddylee17's Avatar
buddylee17 buddylee17 is offline Offline
Posting Whiz

Re: creating arrays

  #2  
29 Days Ago
I believe you have to do something like:
  1. $teamMbrs= array(1 =>$team1, $team2, $team3, $team4, $team5, $team6, $team7, $team8, $team9, $team10, $team11, $team12, $team13, $team14, $team15, $team16);
Lost time is never found again.
- Benjamin Franklin
Reply With Quote  
Join Date: Jun 2008
Location: Phoenix, AZ
Posts: 538
Reputation: R0bb0b is on a distinguished road 
Rep Power: 2
Solved Threads: 50
R0bb0b's Avatar
R0bb0b R0bb0b is offline Offline
Posting Pro

Re: creating arrays

  #3  
29 Days Ago
the array looks right to me, I do know that the keyword "var" is used to declare variables in classes. This doesn't look like a class so delete those "var"s.
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss
Reply With Quote  
Join Date: Mar 2007
Location: GA
Posts: 27
Reputation: blufab is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
blufab blufab is offline Offline
Light Poster

Re: creating arrays

  #4  
29 Days Ago
it is a class. I using daogen, http://www.titaniclinux.net/daogen/, generated source. The variables are pre-existing but I added the array to the class.
Reply With Quote  
Join Date: Jun 2008
Location: Phoenix, AZ
Posts: 538
Reputation: R0bb0b is on a distinguished road 
Rep Power: 2
Solved Threads: 50
R0bb0b's Avatar
R0bb0b R0bb0b is offline Offline
Posting Pro

Re: creating arrays

  #5  
29 Days Ago
Originally Posted by blufab View Post
it is a class. I using daogen, http://www.titaniclinux.net/daogen/, generated source. The variables are pre-existing but I added the array to the class.

in that case you need a "var" in front of your array to declare it and you cannot declare variables with non-constant values without a constructor, also this process(declare variables with non-constant values) must be in a function.
Last edited by R0bb0b : 29 Days Ago at 9:45 pm.
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss
Reply With Quote  
Join Date: Jun 2008
Location: Phoenix, AZ
Posts: 538
Reputation: R0bb0b is on a distinguished road 
Rep Power: 2
Solved Threads: 50
R0bb0b's Avatar
R0bb0b R0bb0b is offline Offline
Posting Pro

Re: creating arrays

  #6  
29 Days Ago
so what you do is declare the array
  1. var $teamMbrs= array();

then create a function, maybe like this
  1. function assignTeamMbrs()
  2. {
  3. $this->teamMbrs[] = $team1;
  4. $this->teamMbrs[] = $team2;
  5. $this->teamMbrs[] = $team3;
  6. $this->teamMbrs[] = $team4;
  7. $this->teamMbrs[] = $team5;
  8. $this->teamMbrs[] = $team6;
  9. $this->teamMbrs[] = $team7;
  10. $this->teamMbrs[] = $team8;
  11. $this->teamMbrs[] = $team9;
  12. $this->teamMbrs[] = $team10;
  13. $this->teamMbrs[] = $team11;
  14. $this->teamMbrs[] = $team12;
  15. $this->teamMbrs[] = $team13;
  16. $this->teamMbrs[] = $team14;
  17. $this->teamMbrs[] = $team15;
  18. $this->teamMbrs[] = $team16;
  19. }

the call that function from the constructor like this
  1. $this->assignTeamMbrs();
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 11:30 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC