Forum Moderators: coopster

Message Too Old, No Replies

Parse Error, unexpected T_STRING with PHP Script

help please! heh

         

zach86

7:03 am on Jul 11, 2003 (gmt 0)

10+ Year Member



I got this code from a site, for an account creation php script... and I've installed it, but now I get the error:

Parse error: parse error, unexpected T_STRING, expecting ']' in c:\inetpub\wwwroot\signup.php on line 3

=\ heres the first part of the php code for that file:

<?php
$DOCUMENT_ROOT = $_SERVER["c:\Inetpub\wwwroot\"];
include($DOCUMENT_ROOT . "helbreath-params.php");
include($DOCUMENT_ROOT . "account-params.php");
include($DOCUMENT_ROOT . "account-lib.php");

$accounts = get_accounts();

if(count($accounts) >= MAX_ACCOUNTS)
$error_message .= "The Account Creation Limit has been reached.<br>";

Its driving me crazy.. If anyone needs all the php files, i'm willing to e-mail them...

Thanks,
Zac

willybfriendly

7:24 am on Jul 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Escape the forward slash at the end of line one and see what happens, i.e.

$DOCUMENT_ROOT = $_SERVER["c:\Inetpub\wwwroot\\"];

Looks to me like that forward slash by itself is escaping the ending quote, which is causing a mess.

WBF

<edit> You probably need to escape all the forward slashes. it is late and I am coded out

jatar_k

7:53 am on Jul 11, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld zach86,

can you specify which is line 3.

zach86

8:07 am on Jul 11, 2003 (gmt 0)

10+ Year Member




Willybfriendly:
The slash thing didnt help =\

jatar_k:

Thanks :-) Im glad to be part of the community!

Line 3 is

include($DOCUMENT_ROOT . "helbreath-params.php");

Timotheos

8:11 am on Jul 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm confused by this line
$DOCUMENT_ROOT = $_SERVER["c:\Inetpub\wwwroot\"];

Shouldn't it be
$DOCUMENT_ROOT = $_SERVER["DOCUMENT_ROOT"];

jatar_k

8:12 am on Jul 11, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I do see a problem

\"];

in that bit you end up escaping the double quotes, hence the error. The parser thinks you never cvlosed the quote.

zach86

8:40 am on Jul 11, 2003 (gmt 0)

10+ Year Member



THANKS! I just tried removing the "\" so now its just

$DOCUMENT_ROOT = $_SERVER["c:\Inetpub\wwwroot"];

That got me further than I was before! :-) It displays the form at the bottom, but now its popped up with a few more errors with other parts of the script, but i'll check it out first, and let ya know my progress! Thanks again! =)

Zac

jatar_k

8:41 am on Jul 11, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



start with the top error and work your way through. Sometimes subsequent errors are produced from one that occurred before.

zach86

10:11 am on Jul 11, 2003 (gmt 0)

10+ Year Member



heh, I'm puzzled... :-\ I zipped up the files, and put em on my site if it is too much trouble for you to look at them?

<snip>

im going to go crazy!

the function of it is, to create a certain user file on my server...

Take Care,
Zac

[edited by: jatar_k at 2:10 pm (utc) on July 11, 2003]
[edit reason] sorry no personal urls [/edit]

willybfriendly

2:45 pm on Jul 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It looks to me as if this section of code is simply setting the paths to the includes.

It also looks like it is set up to run on a Windows machine

Try replacing the forward slashes with back slashes and see what happens. As it is you are escaping things (see my first reply) that you don't want to escape.

Try entering the paths in their entire form. Instead of

include($DOCUMENT_ROOT . "helbreath-params.php");

try

include("c:\\Inetpub\\wwwroot\\helbreath-params.php");

etc.

Or, try moving the files in question to the same directory and simply use

include("helbreath-params.php");

etc.

I am pretty sure that this is the source of the problem, assuming you have installed everything in the proper places and your paths are correct.

WBF

Timotheos

3:14 pm on Jul 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm still confused. $_SERVER is a predefined variable. So what is $_SERVER["c:\Inetpub\wwwroot\"] actually doing?

Thanks,
Tim

<achinghead><scratch1><scratch2></scratch2></scratch1></achinghead>

jatar_k

4:13 pm on Jul 11, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I will third that I think it is that include that is doing weird things. I don't see anything else wrong, necessarily with the code.

Are you hosting it on your local machine or on a windows server? Either way, something isn't right with those paths.

I would first try willybfriendly's suggestion of

Or, try moving the files in question to the same directory and simply use

include("helbreath-params.php");

at least then you can if the script actually works and find out if it is only the include oath that is giving you trouble.

zach86

8:44 pm on Jul 11, 2003 (gmt 0)

10+ Year Member



Yeah, Its hosted on an Windows XP Pro Machine, all files in the same directory... The base directory of where the accounts go.

The php files are in

d:\HBServerFinal\

And the account folder is at

d:\HBServerFinalized\Server\Account

I'll try the new suggestions =) (I'm no expert on php, but I like the challenge of trying to get something to work, a friend wanted me to try it out... I still have to change the error messages, and some text from spanish to english =) but other than that, Its been interesting)

Thanks again for your time, i'll get back to ya =)

(PS, Sorry about posting that link, didn't know I couldnt post my url =) if anyone wants to look at the code, i'll just E-Mail it at your request If thats allowed =) heh)