Re: PHP Error



adrian.bartholomew@xxxxxxxxx wrote:
Im getting an error:

Error: unterminated string literal
Source File: http://98.214.38.110/allfours/site_flash/2.php
Line: 75, Column: 37
Source Code:
if (_ie == true) document.writeln('

___________________________________


with this code:

<?php
session_start();

return code();

function code() {
$user_id = $_SESSION['myusername'];
$tournament_id = $_SESSION['tournament_id'];
$game_id = $_SESSION['game_id'];
$roomNo = $_SESSION['roomNo'];
$portNo = (($roomNo - 1) * 10) + 5000;

return '

<!-- The following code is specified at the beginning of the <BODY>
tag. -->
<SCRIPT LANGUAGE="JavaScript">
<!--
function closeWindow() {
window.opener = "";
window.close();
}

var _info = navigator.userAgent;
var _ns = false;
var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0
&& _info.indexOf("Windows 3.1") < 0);
//--></SCRIPT>

<COMMENT>
<SCRIPT LANGUAGE="JavaScript1.1">
<!--
function closeWindow() {
window.opener = "";
window.close();
}
var _ns = (navigator.appName.indexOf("Netscape") >= 0
&& ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0
&& java.lang.System.getProperty("os.version").indexOf("3.5") < 0)
|| _info.indexOf("Sun") > 0));
//--></SCRIPT></COMMENT>

<!-- The following code is repeated for each APPLET tag -->
<SCRIPT LANGUAGE="JavaScript">
<!--
function closeWindow() {
window.opener = "";
window.close();
}

if (_ie == true) document.write(\'
<OBJECT
classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
width="500" height="500" align="baseline"

codebase="http://java.sun.com/products/plugin/autodl/
jinstall-1_5_0-windows-i586.cab#Version=1,5,0,0">

<param name = "mayscript" value = "true">
<param name="ARCHIVE"
value="client.jar,activation.jar,smtp.jar,mailapi.jar" >
<PARAM NAME="server" VALUE="98.214.38.110:' . $portNo . '" >
<PARAM NAME="bg-pic" VALUE="res/bgrounds/bg' .
$_SESSION['roomNo'] . '.jpg" >
<PARAM NAME="tournamentId" VALUE="' . $tournament_id . '" >
<PARAM NAME="tournamentGameId" VALUE="' . $game_id . '" >
<PARAM NAME="user" VALUE="' . $user_id . '" >
<NOEMBED><XMP>\');

else if (_ns == true) document.write(\'
<EMBED
type="application/x-java-applet;version=1.5.0" width="100"
height="100"
align="baseline"
code="com.caribbeancardsonline.allfours.client.RoomClient"
ARCHIVE="client.jar","activation.jar","smtp.jar","mailapi.jar"
codebase="http://98.214.38.110/allfours/";
server="98.214.38.110:' . $portNo . '" bg-pic="res/bgrounds/bg' .
$roomNo . '.jpg" user= "' . $user_id . '"
tournamentId="' . $tournament_id . '"
tournamentGameId="' . $game_id . '"
pluginspage="http://java.sun.com/products/plugin/autodl/
jinstall-1_5_0-windows-i586.cab#Version=1,5,0,0">
<NOEMBED><XMP>
\');
//--></SCRIPT>

<APPLET code="com.caribbeancardsonline.allfours.client.RoomClient"
ARCHIVE="client.jar,activation.jar,smtp.jar,mailapi.jar"
codebase="http://98.214.38.110/allfours/"; align="baseline"
WIDTH=500 HEIGHT=500>

</XMP>

<param name = "mayscript" value = "true">
<PARAM NAME="java_code"
VALUE="com.caribbeancardsonline.allfours.client.RoomClient">
<PARAM NAME="java_type" VALUE="application/x-java-
applet;version=1.5.0">
<PARAM NAME="server" VALUE="98.214.38.110:' . $portNo . '">
<PARAM NAME="bg-pic" VALUE="res/bgrounds/bg' . $roomNo . '.jpg">
<PARAM NAME="tournamentId" VALUE="' . $tournament_id . '" >
<PARAM NAME="tournamentGameId" VALUE="' . $game_id . '" >
<PARAM NAME="user" VALUE="' . $user_id . '">
<PARAM name="autostart" value="true">
<PARAM NAME="scriptable" VALUE="true">
No Java 2 SDK, Standard Edition v 1.5 support for APPLET!!
</APPLET></NOEMBED></EMBED></OBJECT>

<!--
<APPLET CODE="com.caribbeancardsonline.allfours.client.RoomClient"
ARCHIVE="client.jar,activation.jar,smtp.jar,mailapi.jar"
<PARAM NAME="server" VALUE="98.214.38.110:' . $portNo . '">
<PARAM NAME="bg-pic" VALUE="res/bgrounds/bg' . $roomNo . '.jpg">
<PARAM NAME="tournamentId" VALUE="' . $tournament_id . '" />
<PARAM NAME="tournamentGameId" VALUE="' . $game_id . '" />
<PARAM NAME="user" VALUE="' . $user_id . '">
<PARAM name="autostart" value="true">
No Java 2 SDK, Standard Edition v 1.5 support for APPLET!!
</APPLET>
-->
';
}

?>


I have always found it much simpler to do things in little pieces rather than try to swallow something whole.

I would suggest building a string for what you want to return. That is:

$str = '<!-- The following code is specified at the beginning of the <BODY> tag. -->';
$str .= some_more_stuff
and so on
and then
return $str;

That way what you are writing becomes clearer, much easier to read, and also you will receive php errors for any line that is not correctly done.
.