TheNeedle Posted August 6, 2008 Share Posted August 6, 2008 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 />"; Quote Link to comment Share on other sites More sharing options...
Guest Anonymous Posted August 6, 2008 Share Posted August 6, 2008 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 />"; Quote Link to comment Share on other sites More sharing options...
TheNeedle Posted August 6, 2008 Author Share Posted August 6, 2008 Re: Server timer help So PRINT<<<EOF EOF; is the heredoc function? It injects javascript/ajax into the page? Quote Link to comment Share on other sites More sharing options...
Guest Anonymous Posted August 6, 2008 Share Posted August 6, 2008 Re: Server timer help Well, it's not really a function. You could use echo ''; though heredoc syntax dose have it's advantages. Quote Link to comment Share on other sites More sharing options...
TheNeedle Posted August 6, 2008 Author Share Posted August 6, 2008 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.