Forum Moderators: coopster

Message Too Old, No Replies

Parse Error

         

dektek11

7:28 pm on Jan 13, 2005 (gmt 0)

10+ Year Member



The script works fine in html, but when I place it in a php page, I keep getting:
Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home/public_html/test.php on line 25

function sb10_main()
{
window.status=sb10_messages[sb10_currMsg].substring(0,sb10_index)
sb10_index++
if(sb10_index==(sb10_messages[sb10_currMsg].length+4)){setTimeout('sb10_reset_clear()',sb10_delay);}
else{setTimeout('sb10_main()',sb10_speed)}
}

Line 25:
if(sb10_index==(sb10_messages[sb10_currMsg].length+4)){setTimeout('sb10_reset_clear()',sb10_delay);}

Any ideas?
thx

[edited by: ergophobe at 8:16 pm (utc) on Jan. 13, 2005]
[edit reason] code dump snipped - please read forum charter [/edit]

dektek11

8:11 pm on Jan 13, 2005 (gmt 0)

10+ Year Member



nm, I guess figured it out
if(sb10_index==(sb10_messages[sb10_currMsg].length+4)){setTimeout('sb10_reset_clear()',sb10_delay);}

added / at 'sb10...etc

if(sb10_index==(sb10_messages[sb10_currMsg].length+4)){setTimeout(/'sb10_reset_clear()/',sb10_delay);}

dreamcatcher

8:12 pm on Jan 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Glad you got it sorted dektek11 and welcome to WebmasterWorld. :)

ergophobe

8:18 pm on Jan 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Welcome dektek.

You are missing a ; at the end of the previous line and several other places in the original code.

I would think that the / would give you a parse error. If you want to escape the quotes, it needs to be \', but since you're not in a string, you can't escape quotes there.

Check your missing semicolons and try again.

dektek11

8:34 pm on Jan 13, 2005 (gmt 0)

10+ Year Member



LOL, I'm really tired right now. I meant \', not /' I just typed it wrong here. I'm checking the semicolons, too. Adding the \ get's rid of the parse error, but now it screws up the speed on the text.

See, it works fine the way it is in the original post if it's on an html page. But as soon as I stick it between <?php
?>
I get a parse error.

s1dev

2:36 am on Jan 14, 2005 (gmt 0)

10+ Year Member



This is a javascript function? If so when you stick it between <?php?> tags, PHP is going to try and parse it as a PHP function. The syntax is different between the two languages and PHP won't like it.
To have it render properly, you'll need to echo (or print) each line.

For example:

echo "function sb10_main()";
echo "{";
echo "window.status=sb10_messages[sb10_currMsg].substring(0,sb10_index)";
.
.
.

s1dev

2:37 am on Jan 14, 2005 (gmt 0)

10+ Year Member



or leave it outside of your <?> tags altogether so PHP doesn't try to parse it.

ergophobe

5:43 am on Jan 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




This is a javascript function?

Talk about not seeing the forest for the trees! Yup, that would cause some problems ;-)