...

View Full Version : Cannot use semi-colon in php?



skill3d
02-18-2012, 02:44 PM
I have a javascript pop up code that i would like to add to my forums, i'm using Simple Machines forums and there is a default template that you use to create a new page on the website. This is the default template:


<?php

if (!defined('SMF'))
die('Hacking attempt...');

function Vote4Cash() {
global $context;
$context['page_title'] = 'Title';

function template_main() {
echo 'Information that you want to be displayed to user.';
}

}
?>

Now, i want to add the code below in between the

echo 'Information that you want to be displayed to user.';

Where it says, "Information that you want to be displayed to user." replaced with the following code:



<a href='http://www.google.com' onclick="newwindow.open('http://www.google.com','popup','width=10,height=10,scrollbars=no,resizable=no,toolbar=no,directories=no,loc ation=no,menubar=no,status=no,left=0,top=0'); return false">Click for Pop-Up Window</a>


However, when i try to do so the semi-colon interfere's with the rest of the code, and takes it as if i am closing off the echo command. And when i try to load my webpage i get this error:


Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/rspsman/public_html/Sources/V4c.php on line 14

Any help with this problem would be greatly appreciated, thanks!

skill3d
02-18-2012, 02:49 PM
Very sorry, i meant apostrophe not semi-colon..

abduraooft
02-18-2012, 03:09 PM
echo "<a href='http://www.google.com' onclick=\"newwindow.open('http://www.google.com','popup','width=10,height=10,scrollbars=no,resizable=no,toolbar=no,directories=no,loc ation=no,menubar=no,status=no,left=0,top=0'); return false\">Click for Pop-Up Window</a>";

Nightfire
02-18-2012, 03:11 PM
You can't have a string as

echo '<a href='http://www.google.com' onclick="newwindow.open('http://www.google.com','popup','width=10,height=10,scrollbars=no,resizable=no,toolbar=no,directories=no,loc ation=no,menubar=no,status=no,left=0,top=0'); return false">Click for Pop-Up Window</a>';

You'll get the error you just showed. You will either need to change the apostrophes inside the string to quotations (" ") or escape them with a backslash.



echo "<a href='http://www.google.com' onclick=\"newwindow.open('http://www.google.com','popup','width=10,height=10,scrollbars=no,resizable=no,toolbar=no,directories=no,loc ation=no,menubar=no,status=no,left=0,top=0'); return false\">Click for Pop-Up Window</a>";


or


echo '<a href="http://www.google.com" onclick="newwindow.open(\'http://www.google.com\',\'popup\',\'width=10,height=10,scrollbars=no,resizable=no,toolbar=no,directories=no ,location=no,menubar=no,status=no,left=0,top=0\'); return false">Click for Pop-Up Window</a>';

skill3d
02-18-2012, 05:10 PM
Thanks for the post and rep++ it opened in a new window, thanks much. - Skill3d



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum