Page 1 of 1

String error

Posted: Thu Nov 14, 2002 10:57 am
by innodonni
:? Please help me. I inserted this code into my PHP page:

<?php
function signup($username, $password) {
$def0 = "<html>\n<head>\n<LINK REL=stylesheet TYPE=\"text/css\" HREF=/other/Style.css>\n</head>\n<body><a name=\"top\"></a>\n";
$def1 = "<center><a href=\"/main.html\" target=\"main\" ONMOUSEOVER='rollover9.src=\"/images/2Home2II.jpg\"' ONMOUSEOUT='rollover9.src=\"/images/2Home2.jpg\"'><img src=\"/images/2Home2.jpg\" alt=\"Home\" border=0 width=50 height=20 name=\"rollover9\"></a>\n";
$def2 = "<a href=\"http://pub8.bravenet.com/vote/vote.php? ... 9553&cpv=1\" target=\"main\" ONMOUSEOVER='rollover10.src=\"/images/2Todayspoll2II.jpg\"' ONMOUSEOUT='rollover10.src=\"/images/2Todayspoll2.jpg\"'><img src=\"/images/2Todayspoll2.jpg\" alt=\"Today's Poll\" border=0 width=90 height=20 name=\"rollover10\"></a>\n";
$def3 = "<a href=\"http://pub8.bravenet.com/chat/show.php? ... 9553&cpv=1\" target=\"main\" ONMOUSEOVER='rollover11.src=\"/images/2Chatroom2II.jpg\"' ONMOUSEOUT='rollover11.src=\"/images/2Chatroom2.jpg\"'><img src=\"/images/2Chatroom2.jpg\" alt=\"Chatroom\" border=0 width=85 height=20 name=\"rollover11\"></a>\n";
$def4 = "<a href=\"http://pub8.bravenet.com/guestbook/show ... 9553&cpv=1\" target=\"main\" ONMOUSEOVER='rollover12.src=\"/images/2Guestbook2II.jpg\"' ONMOUSEOUT='rollover12.src=\"/images/2Guestbook2.jpg\"'><img src=\"/images/2Guestbook2.jpg\" alt=\"Guestbook\" border=0 width=85 height=20 name=\"rollover12\"></a>\n";
$def5 = "<a href=\"http://pub8.bravenet.com/forum/show.php ... 9553&cpv=1\" target=\"main\" ONMOUSEOVER='rollover13.src=\"/images/2Forum2II.jpg\"' ONMOUSEOUT='rollover13.src=\"/images/2Forum2.jpg\"'><img src=\"/images/2Forum2.jpg\" alt=\"Forum\" border=0 width=60 height=20 name=\"rollover13\"></a>\n";
$def6 = "<a href=\"/files/Links.html\" target=\"main\" ONMOUSEOVER='rollover14.src=\"/images/2Links2II.jpg\"' ONMOUSEOUT='rollover14.src=\"/images/2Links2.jpg\"'><img src=\"/images/2Links2.jpg\" alt=\"Links\" border=0 width=55 height=20 name=\"rollover14\"></a>\n";
$def7 = "<a href=\"/files/aboutme/aboutme.html\" target=\"main\" ONMOUSEOVER='rollover15.src=\"/images/2Aboutme2II.jpg\"' ONMOUSEOUT='rollover15.src=\"/images/2Aboutme2.jpg\"'><img src=\"/images/2Aboutme2.jpg\" alt=\"About me\" border=0 width=75 height=20 name=\"rollover15\"></a>\n";
$def8 = "<a href=\"mailTo:innodonni@myrealbox.com?subject=query\" target=\"_blank\" ONMOUSEOVER='rollover16.src=\"/images/2E-mail2II.jpg\"' ONMOUSEOUT='rollover16.src=\"/images/2E-mail2.jpg\"'><img src=\"/images/2E-mail2.jpg\" alt=\"E-mail\" border=0 width=50 height=20 name=\"rollover16\"></a>\n</center>\n";
$def9 = "<table>\n<tr><td>\n<p>\n<H2>My website</H2>\nThis site is under construction at the moment so please come back later.<br>You can host your own website free at <a href=\"http://innodonni.iwebland.com/webshell\" target=\"_parent\">http://innodonni.iwebland.com/webshell</a>!";
$de10 = "<p><form method=post action=\"#\"><input type=button style=\"color: #000090; font-family: Arial Rounded MT Bold, Arial; font-weight: bold; font-size: 12pt; background-color: #5000FF\" value=\"Back\" onClick=\"history.back();\"></form></p>\n<p><a href=\"#top\" target=main>Back to top of page</a></p>\n</td></tr>\n</table>\n";
$de11 = "<center><a href=\"main.html\" target=\"main\" ONMOUSEOVER='rollover17.src=\"/images/2Home2II.jpg\"' ONMOUSEOUT='rollover17.src=\"/images/2Home2.jpg\"'><img src=\"/images/2Home2.jpg\" alt=\"Home\" border=0 width=50 height=20 name=\"rollover17\"></a>\n";
$de12 = "<a href=\"http://pub8.bravenet.com/vote/vote.php? ... 9553&cpv=1\" target=\"main\" ONMOUSEOVER='rollover18.src=\"/images/2Todayspoll2II.jpg\"' ONMOUSEOUT='rollover18.src=\"/images/2Todayspoll2.jpg\"'><img src=\"/images/2Todayspoll2.jpg\" alt=\"Today's Poll\" border=0 width=90 height=20 name=\"rollover18\"></a>\n";
$de13 = "<a href=\"http://pub8.bravenet.com/chat/show.php? ... 9553&cpv=1\" target=\"main\" ONMOUSEOVER='rollover19.src=\"/images/2Chatroom2II.jpg\"' ONMOUSEOUT='rollover19.src=\"/images/2Chatroom2.jpg\"'><img src=\"/images/2Chatroom2.jpg\" alt=\"Chatroom\" border=0 width=85 height=20 name=\"rollover19\"></a>\n";
$de14 = "<a href=\"http://pub8.bravenet.com/guestbook/show ... 9553&cpv=1\" target=\"main\" ONMOUSEOVER='rollover20.src=\"/images/2Guestbook2II.jpg\"' ONMOUSEOUT='rollover20.src=\"/images/2Guestbook2.jpg\"'><img src=\"/images/2Guestbook2.jpg\" alt=\"Guestbook\" border=0 width=85 height=20 name=\"rollover20\"></a>\n";
$de15 = "<a href=\"http://pub8.bravenet.com/forum/show.php ... 9553&cpv=1\" target=\"main\" ONMOUSEOVER='rollover21.src=\"/images/2Forum2II.jpg\"' ONMOUSEOUT='rollover21.src=\"/images/2Forum2.jpg\"'><img src=\"/images/2Forum2.jpg\" alt=\"Forum\" border=0 width=60 height=20 name=\"rollover21\"></a>\n";
$de16 = "<a href=\"/files/Links.html\" target=\"main\" ONMOUSEOVER='rollover22.src=\"/images/2Links2II.jpg\"' ONMOUSEOUT='rollover22.src=\"/images/2Links2.jpg\"'><img src=\"/images/2Links2.jpg\" alt=\"Links\" border=0 width=55 height=20 name=\"rollover22\"></a>\n";
$de17 = "<a href=\"/files/aboutme/aboutme.html\" target=\"main\" ONMOUSEOVER='rollover23.src=\"/images/2Aboutme2II.jpg\"' ONMOUSEOUT='rollover23.src=\"/images/2Aboutme2.jpg\"'><img src=\"/images/2Aboutme2.jpg\" alt=\"About me\" border=0 width=75 height=20 name=\"rollover23\"></a>\n";
$de18 = "<a href=\"mailTo:innodonni@myrealbox.com?subject=query\" target=\"_blank\" ONMOUSEOVER='rollover24.src=\"/images/2E-mail2II.jpg\"' ONMOUSEOUT='rollover24.src=\"/images/2E-mail2.jpg\"'><img src=\"/images/2E-mail2.jpg\" alt=\"E-mail\" border=0 width=50 height=20 name=\"rollover24\"></a>\n";
$de19 = "</center>\n</body>\n</html>";
global $default = $def0 . $def1 . $def2 . $def3 . $def4 . $def5 . $def6 . $def7 . $def8 . $def9 . $de10 . $de11 . $de12 . $de13 . $de14 . $de15 . $de16 . $de17 . $de18 . $de19;
global $ok = TRUE;


...and recieved this error message:

Parse error: parse error, expecting `','' or `';'' in /users/iwebland.com/innodonni/webshell/login.php on line 23

The idea was to create a default page that could be written to a file, and I thought the strings were too long, so I decided to make several and concatenate them. But the error merely shifted to line 23.

What's wrong :?:

Posted: Thu Nov 14, 2002 11:18 am
by MeOnTheW3
You need to do your declarations of variables separate to using them.

Code: Select all

&lt;?php
function signup($username, $password) {

global $default;
global $ok;


$default = $def0 . ...
$ok = TRUE;
}
?&gt;

Now you can use default alot cleaner:

Code: Select all

&lt;?php
$default = "&lt;html&gt;\n&lt;....&gt;&lt;/a&gt;\n";
$default .= "&lt;center&gt;&lt;....&gt;&lt;/a&gt;\n";
$default . = "&lt;a......";
?&gt;
$ok = TRUE;

Posted: Fri Nov 15, 2002 6:30 am
by twigletmac
For a huge block of HTML like that that you may want to look into using heredoc format:
http://www.php.net/manual/en/language.t ... ax.heredoc

Makes life a lot easier for me, may help you too.

Mac

Thanks

Posted: Sat Nov 23, 2002 4:01 pm
by innodonni
Thankyou for your help. Just went open source and installed linux on my computer and had to ditch my FTP program, so I can't check it out yet. I'm sure it will work now. Thanks :D

Posted: Sat Nov 23, 2002 6:34 pm
by oldtimer
I really like to break things down and use includes for my big pages. otherwise 1500 lines sucks to read through :lol: