scottiedog Posted February 26, 2010 Share Posted February 26, 2010 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] Quote Link to comment Share on other sites More sharing options...
trq Posted February 27, 2010 Share Posted February 27, 2010 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? Quote Link to comment Share on other sites More sharing options...
scottiedog Posted February 27, 2010 Author Share Posted February 27, 2010 Yes, here is the script. thanks so much for your help... Is this what you meant ? <? include "http://www./myimportlib.php" ?> </div> </DIV> <div align="center"> <script type="text/javascript" src="webticker_lib.js" language="javascript"></script> Quote Link to comment Share on other sites More sharing options...
trq Posted February 27, 2010 Share Posted February 27, 2010 Your including the file via a url, this makes a request to your server. Much quicker to use a direct call to your filesystem. eg; <?php include 'myimportlib.php'; ?> PS: Never use short tags. Quote Link to comment Share on other sites More sharing options...
scottiedog Posted February 27, 2010 Author Share Posted February 27, 2010 Excellent. Thanks very much. I will try that and get back to you with the results. Good of you to help me. Thanks.. Quote Link to comment Share on other sites More sharing options...
scottiedog Posted February 28, 2010 Author Share Posted February 28, 2010 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 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 Quote Link to comment Share on other sites More sharing options...
trq Posted February 28, 2010 Share Posted February 28, 2010 There is no need for that file to echo the html. Just place plain html in there without the <?php tags, your not really using php. Quote Link to comment Share on other sites More sharing options...
scottiedog Posted February 28, 2010 Author Share Posted February 28, 2010 Cheers dude ! As soon as I put that HTML after the php it worked just fine. Thanks so much. Later. Quote Link to comment Share on other sites More sharing options...
Bobski2000 Posted March 2, 2010 Share Posted March 2, 2010 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 :-\ Quote Link to comment Share on other sites More sharing options...
scottiedog Posted March 2, 2010 Author Share Posted March 2, 2010 where did you put the myimportlib.php ? Quote Link to comment Share on other sites More sharing options...
Bobski2000 Posted March 2, 2010 Share Posted March 2, 2010 Root of my site Quote Link to comment Share on other sites More sharing options...
scottiedog Posted March 2, 2010 Author Share Posted March 2, 2010 Change the import myimport.php line too..... change it to what the guy recommended above... Quote Link to comment Share on other sites More sharing options...
Bobski2000 Posted March 2, 2010 Share Posted March 2, 2010 This: <? include "myimportlib.php" ?> To this: <?php include 'myimportlib.php'; ?> Ive tried this Quote Link to comment Share on other sites More sharing options...
scottiedog Posted March 2, 2010 Author Share Posted March 2, 2010 Other than that, I would be stumped to. 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. Quote Link to comment Share on other sites More sharing options...
Bobski2000 Posted March 2, 2010 Share Posted March 2, 2010 live page? I have in the root of my site.. webticker_lib.js main.html <-- this is the html file with the code placed in myimportlib.php This is right? Quote Link to comment Share on other sites More sharing options...
scottiedog Posted March 2, 2010 Author Share Posted March 2, 2010 That´s the problem. Change that main.html to main.php (maybe as a test first, just to check but I reckon that will do it) (remember all your links to that page ) Quote Link to comment Share on other sites More sharing options...
Bobski2000 Posted March 2, 2010 Share Posted March 2, 2010 kinda works...lol, it's not scrolling now.. Quote Link to comment Share on other sites More sharing options...
scottiedog Posted March 2, 2010 Author Share Posted March 2, 2010 go into the .js settings, there´s something in there for that. enjoy Quote Link to comment Share on other sites More sharing options...
Bobski2000 Posted March 2, 2010 Share Posted March 2, 2010 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? Quote Link to comment Share on other sites More sharing options...
scottiedog Posted March 2, 2010 Author Share Posted March 2, 2010 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 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.... ) Quote Link to comment Share on other sites More sharing options...
scottiedog Posted March 2, 2010 Author Share Posted March 2, 2010 EDIT : "Trying to work" Quote Link to comment Share on other sites More sharing options...
Bobski2000 Posted March 2, 2010 Share Posted March 2, 2010 lol, Will let you know how i get on. Thanks for your help as well. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted March 2, 2010 Share Posted March 2, 2010 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. Quote Link to comment Share on other sites More sharing options...
scottiedog Posted March 2, 2010 Author Share Posted March 2, 2010 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. Quote Link to comment Share on other sites More sharing options...
Bobski2000 Posted March 2, 2010 Share Posted March 2, 2010 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.