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

  • SEARCH
  • Home
  • 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 8501249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:09:27+00:00 2026-06-11T01:09:27+00:00

I found this ad rotator script and I want to nest JavaScript inside like

  • 0

I found this ad rotator script and I want to nest JavaScript inside like this below. I get errors thrown how would I accomplish this.

<?php 
// random number 1 - 100 $result_random = rand(1, 100); 

// if result less than or equal 70, display ad1 (70%) 
if($result_random <= 70){ 
  echo "<script type='text/javascript' src='http://myads.com'></script>"; 
} 
// if result less than or equal 90, display ad2 (20%) 
else if($result_random <= 90){ 
  echo "<script type='text/javascript' src='http://myads.com'></script>";
} 
// if result less than or equal 100, display ad3 (10%)
else { 
 echo "<script type='text/javascript' src='http://myads.com'></script>"; 
} 
  • 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-11T01:09:29+00:00Added an answer on June 11, 2026 at 1:09 am

    You can use PHP to output the script source to the user’s browser, but you can’t just include and run Javascript inside of a PHP application.

    Your output of:

    <script type='text/javascript' src='http://myads.com'></script>
    

    Is the correct behavior. The client would then try to include that script source.

    If you’re going to do conditional includes, you’ll want to echo those out between the head tags of your page:

    <html>
      <head>
        <?php
          // process, echo out a <script />
        ?>
      </head>
      <body>...</body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found this question, which is similar to a problem that I would like
Found this Reboot Vista.vbs script on a number of forums. Seems like the whole
found this little code snippet that seems to do what i want, but im
Found this Multimap containing pairs? , but it is not much help How would
found this puzzle HERE ... I made a brute force solution and I would
I found this code online that has a procedure inside a procedure. I cannot
Found this script: function stopRKey(evt) { var evt = (evt) ? evt : ((event)
Found this puzzle inside an image. According to my thinking the total number of
I found this example of Custom LinearLayout on stackoverflow but it throws errors when
I found this open-source library that I want to use in my Java application.

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.