Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8807545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:23:38+00:00 2026-06-14T02:23:38+00:00

i need help with this PHP script that doesn’t works for some reason as

  • 0

i need help with this PHP script that doesn’t works for some reason as below

<?php
.
.
.
echo "<li><a href='#' onclick='print(); return false; _gaq.push(['_trackEvent', 'check', 'test1', 'Print01']); '>";
echo "</a></li>";
.
.                                       
.
?>

if i remove the google tracking event code onclick print() will work without any problem,
does anybody know where is the problem or may be i miss something ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T02:23:40+00:00Added an answer on June 14, 2026 at 2:23 am

    It seems you’re confusing PHP and Javascript code. The “print()” in the onclick handler is Javascript, and unless you have a Javascript function defined that is named print, it’ll fail and the link will be loaded. There’s also no use in having the analytics call after returning false, since it never will run.

    Edit: I misred a bit. You’re using ‘ in the code, as well as using ‘ to delimit the text contained. You’d probably be better off by creating a separate function to handle the click event, or you’ll have to escape the single quotes.

    onclick='print(); return false; _gaq.push([\'_trackEvent\', \'check\', \'test1\', \'Print01\']);'
    

    .. but remember that PHP will also have escape codes, and you might have to escape the \ as well. I’d rather move it out to a separate function:

    <script type="text/javascript">
        function handleClick()
        {
            print();
            _gaq.push(['_trackEvent', 'check', 'test1', 'Print01']);
            return false;
        }
    </script>
    

    Allowing ‘check’, ‘test1’, ‘Print01’ to be provided as arguments to handleClick will also make reuse easier.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need help finishing this statement. It is frustrating that two of the PHP
I need help to use jConfirm with this existing code (php & Jquery &
I have a PHP script that I need to run every minute. I have
I'm currently working on a PHP/MySQL script that does the following, in this order:
I have a php script that generates a binary file (is some kind of
I have a php script that does some processing (creates remittance advice PDFs, self-billing
I really need help this time - Joomla 2.5 and latest K2. I'm using
i need help with this. I'am using JQuery's Dynamic Form plug-in, it duplicates my
I really need help with this last part of my program. I need to
I Really need help in this ... I'm building an application where I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.