Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Oct 2011
    Posts
    25
    Thanks
    5
    Thanked 1 Time in 1 Post

    Cannot use semi-colon in php?

    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:

    Code:
    <?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
    Code:
    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:

    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,location=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:

    Code:
    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!

  • #2
    New Coder
    Join Date
    Oct 2011
    Posts
    25
    Thanks
    5
    Thanked 1 Time in 1 Post
    Very sorry, i meant apostrophe not semi-colon..

  • #3
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    PHP Code:
    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>"
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #4
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    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.

    PHP Code:
    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>"
    or
    PHP Code:
    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>'

  • Users who have thanked Nightfire for this post:

    skill3d (02-18-2012)

  • #5
    New Coder
    Join Date
    Oct 2011
    Posts
    25
    Thanks
    5
    Thanked 1 Time in 1 Post
    Thanks for the post and rep++ it opened in a new window, thanks much. - Skill3d


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •