Jump to content
MakeWebGames

Recommended Posts

Posted

Hi, I'm trying to do a server timer but i keep getting this error.

Parse error: syntax error, unexpected '<' in /home/theneedl/public_html/mainmenu.php on line 37

Newbie error D;

Here's the code from line 36 +

 

print "[b]Time[/b]
";

 <script type="text/javascript">
function startTime()
{
var today=new Date()
var h=today.getHours()
var m=today.getMinutes()
var s=today.getSeconds()
// add a zero in front of numbers<10
m=checkTime(m)
s=checkTime(s)
document.getElementById('txt').innerHTML=h+":"+m+":"+s
t=setTimeout('startTime()',500)
}

function checkTime(i)
{
if (i<10) 
 {i="0" + i}
 return i
}
 </script>
 </head>[/b]
 <body onload="startTime()">
  <div id="txt"></div>

print "<hr />";
Guest Anonymous
Posted

Re: Server timer help

You can not randomly add bits of code any were in your script.

If you need to insert javascript/ajax into your page personally i'd use the heredoc function such as...

 

print "[b]Time[/b]
";
PRINT<<<EOF
 <script type="text/javascript">
function startTime()
{
var today=new Date()
var h=today.getHours()
var m=today.getMinutes()
var s=today.getSeconds()
// add a zero in front of numbers<10
m=checkTime(m)
s=checkTime(s)
document.getElementById('txt').innerHTML=h+":"+m+":"+s
t=setTimeout('startTime()',500)
}

function checkTime(i)
{
if (i<10) 
 {i="0" + i}
 return i
}
 </script>
 </head>[/b]
 <body onload="startTime()">
  <div id="txt"></div>
EOF;

print "<hr />";
Guest Anonymous
Posted

Re: Server timer help

Well, it's not really a function. You could use echo ''; though heredoc syntax dose have it's advantages.

Posted

Re: Server timer help

echo sounds familiar, must of seen it before.

I'm more familiar with vb, did abit of it in school. Only reason i understand the if statements and what not lol.

 

btw, ty it worked great!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...