Page 1 of 2

Whats wrong?????

Posted: Fri Aug 30, 2002 6:13 am
by Dale
In my code i have this error:

Code: Select all

Parse error: parse error, unexpected ']', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /var/www/html/dale/xen/install.php on line 104
Heres line 104:

Code: Select all

$time = time();
Whats wrong???

Posted: Fri Aug 30, 2002 6:45 am
by Dale
Line 100 to Line 110:

Code: Select all

$from = array("{\$prefix}","\$language");
	$to = array("$prefix","$settingїlanguage]");
	$file = str_replace($from, $to,$file);
	$time = "time()";
	$fileї] = "INSERT INTO {$prefix}users (id, username, password, status, regdate, email) VALUES('1', '$settingїadmin_username]', '$settingїadmin_password]', '99', '$time', '$settingїadmin_email]')";
	$fileї] = "INSERT INTO {$prefix}settings VALUES('boardname', '$settingїboardname]')";
	$fileї] = "INSERT INTO {$prefix}settings VALUES('url', '$settingїurl]')";
	$fileї] = "INSERT INTO {$prefix}settings VALUES('language', '$settingїlanguage]')";
	$fileї] = "INSERT INTO {$prefix}settings VALUES('cookiename', '$settingїcookiename]')";
	$fileї] = "INSERT INTO {$prefix}settings VALUES('cookiepath', '$settingїcookiepath]')";

Posted: Fri Aug 30, 2002 7:20 am
by twigletmac
When I try and run that code the parse error doesn't occur so you might want to post the next ten lines up from 100 (89-99). Stick them into [ php ] [/ php] tags (with the spaces removed) so that there'll be some syntax highlighting.

To save you a little bit of typing you can change

Code: Select all

$from = array("{\$prefix}","\$language"); 
$to = array("$prefix","$settingїlanguage]");
to

Code: Select all

$from = array('{$prefix}', '$language'); 
$to = array($prefix,$settingї'language']);
Also put single quotes around your array elements, eg. $setting['language'] instead of $setting[language] if you put your error reporting at it's highest level you'll get a lot of errors like this

Code: Select all

Notice: Use of undefined constant language - assumed 'language' in d:\yourweb\test.php on line xxx
which basically means that the PHP engine is having to lots of work it doesn't need to because there aren't quotes around array elements.

Mac

Posted: Fri Aug 30, 2002 7:22 am
by Dale
I'll try that now m8 ;)

Posted: Fri Aug 30, 2002 7:25 am
by Dale
Done that but now a new error appeared...
Parse error: parse error, unexpected '}' in /var/www/html/dale/xen/install.php on line 102
Heres line 95 to 105:

Code: Select all

<TR><TD BGCOLOR="$layoutї'tdbgcolor2']" CLASS="tdbg2">Cookie domain:</TD><TD BGCOLOR="$layoutї'tdbgcolor2']" CLASS="tdbg2"><INPUT TYPE="text" NAME="settingї'cookiedomain']" SIZE="40" VALUE="$settingї'cookiedomain']">(If unsure, leave empty)</TD></TR>
<TR><TD BGCOLOR="$layoutї'tdbgcolor2']" CLASS="tdbg2">Admin username:</TD><TD BGCOLOR="$layoutї'tdbgcolor2']" CLASS="tdbg2"><INPUT TYPE="text" NAME="settingї'admin_username']" SIZE="40" VALUE="$settingї'admin_username']"></TD></TR>
<TR><TD BGCOLOR="$layoutї'tdbgcolor2']" CLASS="tdbg2">Admin password:</TD><TD BGCOLOR="$layoutї'tdbgcolor2']" CLASS="tdbg2"><INPUT TYPE="password" NAME="settingї'admin_password']" SIZE="40" VALUE="$settingї'admin_password']"></TD></TR>
<TR><TD BGCOLOR="$layoutї'tdbgcolor2']" CLASS="tdbg2">Admin email:</TD><TD BGCOLOR="$layoutї'tdbgcolor2']" CLASS="tdbg2"><INPUT TYPE="text" NAME="settingї'admin_email']" SIZE="40" VALUE="$settingї'admin_email']"></TD></TR>
<TR><TD BGCOLOR="$layoutї'tdbgcolor2']" CLASS="tdbg2" COLSPAN="2"><INPUT TYPE="submit" VALUE="Continue" NAME="submit">
END_HTML;

}}else{

if($step==4)

[EDIT]UPDATED SCRIPT[/EDIT]

Posted: Fri Aug 30, 2002 7:34 am
by twigletmac
Try changing:

Code: Select all

}}else{ 

if($step==4)
to

Code: Select all

} elseif ($step == 4) {
and in the big heredoc block change things like

Code: Select all

$layoutїtdbgcolor2]
to

Code: Select all

{$layoutї'tdbgcolor2']}
Mac

Posted: Fri Aug 30, 2002 7:45 am
by Dale
Done that now this:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /var/www/html/dale/xen/install.php on line 34
Line 34:

Code: Select all

{		$mysqlї'sql_host'] = "localhost";

Posted: Fri Aug 30, 2002 7:47 am
by twigletmac
The error didn't lie, you were missing a } which is why PHP thought the ? was unexpected, try

Code: Select all

<FORM ACTION="{$_SERVERї'PHP_SELF']}?step=$stepnum" METHOD="POST">
instead of

Code: Select all

<FORM ACTION="{$PHP_SELF?step=$stepnum" METHOD="POST">
Mac

Posted: Fri Aug 30, 2002 7:49 am
by twigletmac
You changed the problem just as I posted that solution so now what I would say is 'post more code' those sorts of parse errors are generally caused by something going wrong further up so post the 10 lines before the line that the error is being reported on.

Mac

Posted: Fri Aug 30, 2002 7:51 am
by Dale
Sorry Twig for <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> you around.... :D

Line 25 - 45:

Code: Select all

&lt;META HTTP-EQUIV='Content-Type" CONTENT="text/html; charset=iso-8859-1"&gt;
  &lt;/HEAD&gt;
  &lt;BODY BGCOLOR="{$layout&#1111;'bgcolor']}" TEXT="{$layout&#1111;'text']}" LINK="{$layout&#1111;'link']}" ALINK="{$layout&#1111;'alink']}" VLINK="{$layout&#1111;'vlink']}"&gt;
   &lt;FORM ACTION="{$_SERVER&#1111;'PHP_SELF']}?step=$stepnum" METHOD="POST"&gt;
    &lt;TABLE BGCOLOR="{$layout&#1111;'table_bgcolor']}" cellpadding="3" cellspacing="1" width="{$layout&#1111;'table_width']}" ALIGN="center"&gt;
      &lt;TR&gt;
        &lt;TD BGCOLOR="{$layout&#1111;'tdbgcolor2']}" CLASS="tdbg2"&gt;END_HTML;
if(!$step) 
{	if(!$mysql)	
{		$mysql&#1111;'sql_host'] = "localhost";
		$mysql&#1111;'prefix'] = "xen_";	}	

echo &lt;&lt;&lt;END_HTML    
MySQL Host:&lt;/TD&gt;&lt;TD BGCOLOR="{$layout&#1111;'tdbgcolor2']}" CLASS="tdbg2"&gt;&lt;INPUT TYPE="text" NAME="mysql&#1111;'sql_host']}" VALUE="{$mysql&#1111;'sql_host']}"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;    &lt;TD BGCOLOR="{$layout&#1111;'tdbgcolor2']}" CLASS="tdbg2"&gt;MySQL 
Username:&lt;/TD&gt;&lt;TD BGCOLOR="{$layout&#1111;'tdbgcolor2']}" CLASS="tdbg2"&gt;&lt;INPUT TYPE="text" NAME="mysql&#1111;'sql_user']}" VALUE="{$mysql&#1111;'sql_user']}"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;    &lt;TD BGCOLOR="{$layout&#1111;'tdbgcolor2']}" CLASS="tdbg2"&gt;MySQL 
Password:&lt;/TD&gt;&lt;TD BGCOLOR="{$layout&#1111;'tdbgcolor2']}" CLASS="tdbg2"&gt;&lt;INPUT TYPE="password" NAME="mysql&#1111;'sql_password']}" VALUE="{$mysql&#1111;'sql_password']}"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;    &lt;TD BGCOLOR="{$layout&#1111;'tdbgcolor2']}" CLASS="tdbg2"&gt;
MySQL Database:&lt;/TD&gt;&lt;TD BGCOLOR="{$layout&#1111;'tdbgcolor2']}" CLASS="tdbg2"&gt;&lt;INPUT TYPE="text" NAME="mysql&#1111;'sql_db']}" VALUE="{$mysql&#1111;'sql_db']}"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;    &lt;TD BGCOLOR="{$layout&#1111;'tdbgcolor2']}" CLASS="tdbg2"&gt;
Prefix:&lt;/TD&gt;&lt;TD BGCOLOR="{$layout&#1111;'tdbgcolor2']}" CLASS="tdbg2"&gt;&lt;INPUT TYPE="text" NAME="mysql&#1111;'prefix']}" VALUE="{$mysql&#1111;'prefix']}"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;    &lt;TD BGCOLOR="{$layout&#1111;'tdbgcolor2']}" CLASS="tdbg2" COLSPAN="2"&gt;

&lt;INPUT TYPE="submit" VALUE="Continue" NAME="submit"&gt;END_HTML;

Posted: Fri Aug 30, 2002 7:58 am
by twigletmac
Heredoc format (the <<<END_HTML ... END_HTML; bit for the uninitiated) is very tempramental. Basically go through your code and make sure that all END_HTML; statements are on their own line with no tabs or spaces in front of the END_HTML; or behind it (that's what the unexpected whitespace error is caused by). Also make sure that there are no tabs or spaces after the <<<END_HTML bit.

Mac

Posted: Fri Aug 30, 2002 8:04 am
by Dale
ok every END_HTML is on its own line and theres no spaces infront or behind it.

Now the error has changed to line 35

And line 35 has this:

Code: Select all

{		$mysql&#1111;'sql_host'] = "localhost";
Shall i get rid of the space in between { and $mysql ???

Posted: Fri Aug 30, 2002 10:33 am
by Dale
^ Sorted That Problem Out ^

Now another one...
Parse error: parse error, unexpected '}' in /var/www/html/dale/xen/install.php on line 49

Line 49:

Code: Select all

} elseif ($step == 2) {

Posted: Fri Aug 30, 2002 11:26 am
by twigletmac
Do you have an opening if for that if..else statement?

Mac

Posted: Fri Aug 30, 2002 11:31 am
by Dale
Check Your PM's