View Full Version : Help to make PHP Content Switcher work
Ripsaw
01-04-2016, 08:35 PM
Beverlyh, I have been working my way through your blog feed and would like to set up your PHP Content Switcher script to work with the Gif Player that you assisted with yesterday.
The blog I am referring to is this http://www.dynamicdrive.com/forums/entry.php?305-PHP-Stylesheet-Content-Switcher-with-Save-Cookie
And the Gif Player topic is this http://www.dynamicdrive.com/forums/showthread.php?79338-More-than-one-Gif-Player-on-a-web-page
The idea would be to use the pagination aspect of the Content Switcher script to load different chapters of an online tutorial with each chapter showing several animated Gifs as learning aids. The last loaded page will save so that users can return without losing their place.
I can visualize how this would work but cannot get the sample code from the blog working for me. I haven't used PHP before but your tutorial reads logically. I therefor conclude that my problem lies with my web space. Are there perhaps any special requirements to run the script?
Beverleyh
01-04-2016, 09:23 PM
Not really. You only need a server running PHP, which most web host accounts will be set up to provide (unless maybe you're using a really basic freebie account, but the lack of PHP still seems unlikely)
You can check that you have PHP on your server by creating a file in Notepad with this inside;
<?php phpinfo(); ?>Now save the file as "info.php" and upload it to your web server. Make sure that the file is named "info.php" and not "info.php.txt" otherwise the PHP won't parse when you view it via a web browser.
When you view the file in a web browser (the URL will be something like http://my website.com/info.php ) you should see loads of server info with a blue PHP banner. If that's the case , you're good to go.
Ripsaw
01-04-2016, 10:05 PM
Thank you once again for your prompt reply. The info.php page does display a huge list of server details so I am sure I can work with PHP. The file extension was probably my oversight and reason for my failed tests. Special test pages for the script using a .php file extension do work now you have pointed it out. Is there any way to have this work with pages ending with a .htm or .html extension because I have many files and links already configured that will create much work to change to .php
Please let me know if anything is possible because I would really love to use the script.
Beverleyh
01-04-2016, 10:18 PM
Something *may* be possible, but first, can you find out if you can use an ".htaccess" file on your server?
There might be an option to create one in your web host control panel, or if you can't see anything obvious, a quick email to your host asking if you can use htaccess will help clear things up.
Let me know what you find out.
Ripsaw
01-05-2016, 08:11 AM
Yes I can use htaccess files. What next?
Beverleyh
01-05-2016, 09:22 AM
First rename the "info.php" file to "info.htm" - we're going to make some server changes so that the .htm version of the page can parse PHP. It might not work, but we'll give it a try...
Go to http://deano.me/2015/12/php-inside-html-files-using-htaccess/ and scroll down to the "Different Method" section. Apply each of the examples in turn to your ".htaccess file" at the root of your website. Between each line-test, save the ".htaccess" file and view your "info.htm" web page in a browser.
If one of these lines allows you to view the server info with a blue PHP banner from within the "info.htm" file, it means you've made your server parse any PHP from within any htm/html page, and you should now be able to use the PHP Content Switcher Script (or any other PHP script ) in your existing .htm or .html pages.
Ripsaw
01-05-2016, 10:47 AM
It works! You are my hero!
Beverleyh
01-05-2016, 10:55 AM
No problem. Glad it worked :)
Ripsaw
01-05-2016, 12:16 PM
One last thing... Will the htaccess trick affect any other scripts of have any adverse effects anywhere else?
Beverleyh
01-05-2016, 12:21 PM
I shouldn't affect any other scripts. The only thing that it will do is to make the server work a little harder, which may have the effect of slowing down web pages if you're using shared hosting, or if the script is resource intensive (performing a lot of iterations or querying databases, etc.). It shouldn't be perceivable with this simple script though.
Ripsaw
01-05-2016, 12:23 PM
That is good news. Thank you once again for your insight Beverleyh!
Beverleyh
01-05-2016, 12:24 PM
Happy to help :)
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.