473,385 Members | 1,400 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,385 software developers and data experts.

Parse Error

Hi-

I'm having a problem with a script. I get the following parse error:

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting ']'

Here is the line of code:
Expand|Select|Wrap|Line Numbers
  1. $ownerName = $folders[$foldersSize-1];\n
  2.  
Here is some of the code around it:
Expand|Select|Wrap|Line Numbers
  1. $html = "<?php \n
  2.                         \n
  3.                         include 'memberspace.php';\n
  4.                         include 'UploadProgressMeter.class.php';\n
  5.                         \$fileWidget = new UploadProgressMeter();\n
  6.  
  7.                         $currentDir = getcwd();\n
  8.  
  9.                          $folders = explode( \"/\", $currentDir );\n
  10.  
  11.                         $foldersSize = sizeof($folders);\n
  12.  
  13.                            $ownerName = $folders[$foldersSize-1];\n
  14.  
  15.                         $ownerName = ucwords($ownerName);\n
  16.  
  17.                         $st = $ownerName;\n
  18.                         $len = strlen($st);\n
  19.                         if ($st[$len-1] == \"s\") { \n
  20.                                 $ownerName = $ownerName.'\'';\n 
  21.                             }\n
  22.                             else { \n
  23.                                 $ownerName = $ownerName.'\'s';\n
  24.                             }\n
Please help!

Thanks.
Sep 11 '07 #1
8 1077
The code works fine in a regular page, but the problem I have here is that php is building a different page here and it's not working.
Sep 11 '07 #2
Atli
5,058 Expert 4TB
Hi goatchaps. Welcome to The Scripts!

If the \n at the end of the line is a part of the code, try removing it.

If it is not, please post the lines directly above it. They might be the cause of the problem.
Sep 11 '07 #3
Expand|Select|Wrap|Line Numbers
  1.  
  2.  $html = "<?php 
  3.  
  4.                         include 'memberspace.php';
  5.                         include 'UploadProgressMeter.class.php';
  6.                         $fileWidget = new UploadProgressMeter();
  7.  
  8.                 $currentDir = getcwd();
  9.  
  10.                      $folders = explode( \"/\", $currentDir );
  11.  
  12.                         $foldersSize = sizeof($folders);
  13.  
  14.                        $ownerName = $folders[$foldersSize-1]; // line with error
  15.  
  16.                 $ownerName = ucwords($ownerName);
  17.  
  18.                         $st = $ownerName;
  19.                         $len = strlen($st);
  20.                         if ($st[$len-1] == \"s\") { 
  21.                                 $ownerName = $ownerName.'\'';
  22.                             }
  23.                             else { 
  24.                                 $ownerName = $ownerName.'\'s';
  25.                             }
  26.  
Sep 12 '07 #4
Forgot to say in the last post that I got the same error and the code above is the current code.
Sep 12 '07 #5
These are the lines above it:

Expand|Select|Wrap|Line Numbers
  1.  
  2.  //
  3.     // Generate a new member space for a user
  4.     //
  5.      function generateMemberSpaceHome()
  6.     {
  7.         if( $this->hasMemberSpace )
  8.         {
  9.             $html = "<?php 
  10.  
  11.                         include 'memberspace.php';
  12.                         include 'UploadProgressMeter.class.php';
  13.                         $fileWidget = new UploadProgressMeter();
  14.  
  15.  
Sep 12 '07 #6
Atli
5,058 Expert 4TB
Ahh ok now I see.

You are trying to get the element at index number ($folderSize -1) from the $folders array, from within the string?

The code you are using there can not be put directly inside a string. It will work outside it but not within it.

Try removing it from the string:
Expand|Select|Wrap|Line Numbers
  1. $html ".......". $folders[$folderSize -1] ." .....";
  2.  
Sep 12 '07 #7
It looks like it worked, still need to do some testing, but I get no errors. I had to concatenate the $st[$len-1] also.

Thanks a bunch!

new code:

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. $ownerName = ". $folders[$foldersSize-1] .";
  4.  
  5. $ownerName = ucwords($ownerName);
  6.  
  7. $st = $ownerName;
  8.  
  9. $len = strlen($st);
  10.  
  11.     if (". $st[$len-1] ." == \"s\") { 
  12.         $ownerName = $ownerName.'\''; 
  13.     }
  14.  
  15.  
Sep 12 '07 #8
Atli
5,058 Expert 4TB
Glad you got it working.
Don't hesitate to post back if you have any more problems we can help with.
Sep 12 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Steven | last post by:
I got a "Parse error: parse error in ..." in this line: if(empty($_POST){ ..... But if I fist assign $ssn=$_POST; and then if(empty($ssn){ ... it is working. Any advice? Thanks in advance.
1
by: H.L Bai | last post by:
hi, everybody i meet a parse error when i used the xml4c. any proposal is helpful. The error is following .../XMLRegionHandler.h:59 parse error before '*' .../XMLRegionHandler.h:60 parse...
2
by: Vittal | last post by:
Hello All, I am trying to compile my application on Red Hat Linux 8 against gcc 3.2.2. Very first file in application is failing to compile. I tried compiling my application on Linux 7.2...
21
by: BWIGLEY | last post by:
Basically I've just started making a game. So far it makes an array 25 by 20 and tries to make five rooms within it. In scr_make_room() there's parse errors: 20 C:\c\Rooms\Untitled1.c parse error...
6
by: trevor | last post by:
Incorrect values when using float.Parse(string) I have discovered a problem with float.Parse(string) not getting values exactly correct in some circumstances(CSV file source) but in very similar...
5
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C++ programming. FYI Although I have called...
1
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C programming. FYI Although I have called this...
1
by: Phaelle | last post by:
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' What does that error mean? I canīt find the mistake!! In another script, I have got another kind of mistake : parse...
2
by: Lawrence Krubner | last post by:
Imagine a template system that works by getting a file, as a string, and then putting it through eval(), something like this: $formAsString = $controller->command("readFileAndReturnString",...
5
by: goldtech | last post by:
SAX XML Parse Python error message Hi, My first attempt at SAX, but have an error message I need help with. I cite the error message, code, and xml below. Be grateful if anyone can tell me...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.