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 8878401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:42:11+00:00 2026-06-14T19:42:11+00:00

I’m testing a script to automate advertisement read from a txt file) i want

  • 0

I’m testing a script to automate advertisement read from a txt file) i want to use this because it was the one i already had and was working and only needed a few changes, however, something stopped working and i dont know what’s wrong, i’m checking the output and everthing seems fine on the javascript but for some reason it doesn’t work, it comes with unexpected token illegal and with the uncaught syntax error
below is the code. Any Help is appreciated

PHP/javascript combined code

<?php 
    $adsf = "test.txt";
    $count = 0;
    $frd = fopen ($adsf,'r');
    $artest = array();
    $artest2 = array();
    $artest3 = array();
      while(!feof($frd))
       {

         $artest[$count] = fgets($frd);
         $count++;
        }
      fclose($frd);


      $t = 0;
      while($t < $count)
        {
        $artest2[$t] = str_replace("\n" ,'', $artest[$t]);
          $artest3[$t] ="\"".$artest2[$t]."\", ";

          $t++;
        }    





          unset($artest3[$t - 1]);
          shuffle($artest3);
          $t = 0;
         while ($t < $count)
           {

            $jsr = $jsr.$artest3[$t - 1];
            $t++;

            }

               //$jsr. = "\"test 1 test 2 test 3\", ";
            $jsr = $jsr." \"Advertise Here come to Lot 28 or Click <a href=\\\"pub.php\\\" target=\\\"_blank\\\">HERE</a> For More Information\" ";
       ?>


             var avs = new Array ( <?echo $jsr; ?>);

             //var cron = 60;
              var sub = 0;
             function show5(){
                if (!document.layers&&!document.all&&!document.getElementById)
                return




               //change font size here to your desire
               myclock="<font size='2' face='Arial' ><b>"+avs[sub]+"</b></font>"
              if (document.layers){
                  document.layers.liveclock.document.write(myclock)
                  document.layers.liveclock.document.close()
                  }
                 else if (document.all)
                   liveclock.innerHTML=myclock             
                   else if (document.getElementById)
                    document.getElementById("liveclock").innerHTML=myclock

                    ;
                  sub++;

                  if(sub > <? echo $count - 1; ?>)
                   {
                      sub = 0;

                       }
                   setTimeout("show5()",5000)
                 }


             window.onload=show5

and the problem comes on the array, if i put nothing on the txt file everythng works ok but if i try tiping any thing, used to be working but now comes with the “uncaught syntax error unexpected token illegal” and i checked the quotes and are fine.

  • 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-14T19:42:12+00:00Added an answer on June 14, 2026 at 7:42 pm

    This is a bad bad bad bad bad BAD idea:

             var avs = new Array ( <?echo $jsr; ?>);
    

    Look at all the escaping you have to do while you’re building up $jsr in the PHP code. Whereas, if you were doing this properly, with json_encode(), you’d simply build up an array of values in PHP, e.g.

    $jsr = array();
    $jsr[] = "Look ma, a single quote '!!!!"
    $jsr[] = 'Hey pa, double quote here "!!!';
    

    and then

    var avs = <?php echo json_encode($jsr) ?>;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
i want to parse a xhtml file and display in UITableView. what is the
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.