Jump to content

php script problem - only a 4k script, so what on earth could be wrong ?


Recommended Posts

Hi there everyone.

 

Totally new to php and to this site. Been going round in circles for hours on something....... Wonder if anyone can help.

 

I have a website which is running a tiny php file on the index to call for some text for a horizontal ticker. I have attached the script for you to see, maybe you can see straight away what the problem is ?

 

The ticker is from this link..... http://www.mioplanet.com/rsc/newsticker_javascript.htm

 

At the bottom it says you can use a php file to determine the text, so this is what I did as the ticker is on multiple pages and needs to be updated daily, sometimes multiple times daily. It works fine when it works but why oh why does it hang for 5 - 15 seconds before it brings in the text, then completing the page ?

 

The symptom is that the page loads down to the php script fast (as usual) then hangs whilst grabbing the text from the script, it can take 10 seconds or more to grab this 4k script.....

 

Surely that is not right ?

 

The script on the page is as follows, this calls for the .php which is in the same root directory of the domain (so its not like it has to go looking for it for it or anything !

 

Any ideas anyone ?

 

[attachment deleted by admin]

Link to comment
Share on other sites

Considering the fact that there is no php (well, no need for any) within the myimportdb.php file it could just as easily be a simple text file. What I assume they are suggesting is you might want to include a php file to get data from a database or feed or somewhere else.

 

There is nothing in the attached file that would cause your script to hang. Can we see how your including it within the `ticker` div?

Link to comment
Share on other sites

Hi Thorpe,

 

Its working great now. Thanks so much for your advice.

 

One other question. I was just trying to add a link into the text somewhere (by adding a a href)... But everytime I add it it then comes up with an error on that line, so I must be writing something wrong  :shrug:

 

Not really a surprise as I am a Newb, but could you check this and see what is wrong with it ?

 

</style><span style='background-color:#227004;'>  <font color=#ffffff><a href="www.mysite.com/page">Want this to be a link in white text</a></font>  </span>   Standard Text written here, working fine;

 

I add this to the myimportlib.php just before the end    ";?>  It is the last line of text I want, and is just in addition to the otehr 4 lines of text.

 

Parse Error syntax error, unexpected T_STRING, expecting ',' or ';'

 

What should this line of text look like to add a Link ?

 

Also, is there a good site you can recommend where I can get written codes like this, so I can copy and paste etc ?

 

Cheers

 

Scott

 

Link to comment
Share on other sites

Im trying to use this very same script. Like you i've been trying to sort this for hours! lol

 

Here's my problem...

 

Ive uploaded the webticker_lib.js file to the root of my site.

Pasted this into my html file:

<DIV ID="TICKER" STYLE="overflow:hidden; width:520px">
  <? include "myimportlib.php" ?>
</DIV>
<script type="text/javascript" src="webticker_lib.js" language="javascript"></script>

 

And tried to create the myimportlib.php file...

So i looked at scottiedog's php file to see if id done things right, and i hadn't so just as a test i thought i'd tried that.

Just like scottiedog i need to be able to just edit the one file and updated daily, but also for someone else to do without having to change the html file. (If that makes sense?)

 

It still doesn't work. All i get is a white line where it should be and no scrolling text.. What am i doing wrong? Any help would be nice, thanks in advance..

 

Bobski  :-\

Link to comment
Share on other sites

Other than that, I would be stumped to.  :confused:

 

It took me a while to get the php script file to work, had to try varying script structures before it did actually work - but it was coming up with file errors across the ticker when there was a problem........

 

Actually, I think I might have the answer... did you rename the live page from .html to .php ?  I am pretty sure it was white black when I had it still as a .html page

 

If not, I am sure the dude here will be able to help though.

 

 

Link to comment
Share on other sites

Ok, ive changed the html file to php that seems to be ok. But if i wanted to add this code:

<DIV ID="TICKER" STYLE="overflow:hidden; width:520px">
  <? include "myimportlib.php" ?>
</DIV>
<script type="text/javascript" src="webticker_lib.js" language="javascript"></script>

 

to 6 or 7 pages of my site then what your saying is that all the pages would have to be changed to php, but they are all html?

 

i thought that the code was to be used within html?

Link to comment
Share on other sites

Right, it is a good question. I could only get it to work when I changed the names of my pages to .php but I think that is because its using a .php as the imported text file.

 

Like the dude said above, there is actually no need to use .pp for a simple text input and indeed my ".php" file didnt actually have anything worth php-ing, so I guess that if you import via a text file then you wont need to change the php extensions...

 

this is complete guess work to be honest, based upon what the experienced guy said. I just changed the file names to php and reuploaded them, didnt bother me, and its working fine so I aint ammending it....

 

Let me know how it goes. I´d be interested. I think maybe the experienced guy will come in later anyway, and will either confirm what I say  :D or say I am speaking complete crap and then give you the facts... (as i said, i could be speaking total rubbish, its just my newb brain working....  :o)

Link to comment
Share on other sites

By default, web servers only cause .php files to be passed to the php language engine. Therefore, if you want to put any php code, such as a <?php include(...); ?>, into a file, you would need to make that main file a .php file.

 

You can change this default response so that other file endings are also passed to the php language engine. You can easily do this if you have administrative access to your web server and it is sometimes possible at the account level, but that would require some specific knowledge about what your web server is and how php is configured on it.

Link to comment
Share on other sites

Ok, I was half right... ha

 

I just changed the pages I wanted it on to .php (originally html) - I assume there is no problem with doing this ? Everything seems to be working just fine....

 

Just make sure there couldnt be any background problems with changing the files to .php ?

 

Thanks.

Link to comment
Share on other sites

I love the idea that i can alter just the one file. Don't really want to start changing html's to php if i can help it.

 

So is there a problem with this code, cause the way i read about it, it's supose to go into a html file and work, instead i had to change my index page from html to php for it to work.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.