Tag: php

Fixing “Too many redirects” error in MediaWiki

I run a wiki for my ParrotCichlid.com fish fancier’s site, based on “MediaWiki.” It had been running fine, except for an increasing problem with spam, but one day it simply stopped working. Browsing to the site would result in the following error message:

Too many redirects occurred trying to open “http://parrotcichlid.com/book/index.php/Main_Page”. This might occur if you open a page that is redirected to open another page which then is redirected to open the original page.


(Click to enlarge image)

Continue reading

dotProject Recipe: add a “Complete this task” checkbox to todo list

completionCheckbox.jpg

To allow one-click completion of a task, we added a checkbox to each row of the task “to-do” lists in dotProject.

Usually I try to borrow functions from other places in the application and adapt them to the new location. In this case the completion function was borrowed from the “progress” drop-down menu, on the add-edit Task screen.

The check box submits the same values as if 100% were selected from the drop-down menu.

Continue reading

Use server-side application variables to drive client-side scripts

You can use serverside variables to drive client-side javascripts. Server-side variables get processed and the results output by the time the page is rendered, so the value of the variable can be used in client-side functions.

In an ASP application I’m working with, I wanted a different tooltip to show up on each tab, depending on what the tab title was. There is a server-side variable called “tabs[i].title”. So I created a little client-side function to test the value of the title on each tab.

 
<script>
var tabName ;

function whichTab(tabTitle){
   if (tabTitle == 'Summary'){
   tabName = Summary;
}
else if (tabTitle == 'Plan Details'){
   tabName = PlanDetails;
}
else if (tabTitle == 'Certifications'){
   tabName = Certifications;
}
else if (tabTitle == 'Transcript'){
  tabName = Transcript;
}
}
</script>
Continue reading

PHP Alternating Color Table Rows for Drupal or Dreamweaver sites

This is based on the great tutorial by phpfreak at phpfreaks.com For a more complete explanation of this, take a look at his article.

The main variation I have made here is to adapt it for the drupal database and to separate the HTML more from the PHP to make it easier for designers to alter without needing to escape the code characters: a big source of errors for those of us who are not writing code day in and day out.

This will also work well dropped into a Dreamweaver-created php site – just change “nid” and “title” to whatever fields you want to display instead, and use the query dreamweaver generates when you define a recordset.

If you are new at this, it may go more smoothly if you first create a dynamic site in Dreamweaver, then create a dynamic table with whatever fields you want, THEN add in the additional code to generate the colors by comparing that file and this.

Continue reading

Drupal: Suggestions for improving Drupal’s Book Module – Part 2: Navigation

1. Navigation should be visible most of the time. The first time I looked through a book created with the Drupal’s book module, I recall being confused about how to proceed through the document. My confusion resulted from starting on a long page, so that the “previous/up/next” navigation had fallen below the “fold.” Since I was new to Drupal-based books, I wasn’t even aware it was there.


A long page where navigation has dropped below the fold.

The only other visible navigation which was relevant to the book was the breadcrumb trail at the top of the page, which allows the reader to jump “up” a level but not backwards and forwards between pages of a chapter.

I did figure the system out within a few minutes, but I’ve watched others who are less interested in “figuring things out” attempt fruitlessly to find their way around such issues, and pretty much give up. It is amazing how people don’t think to look around the page, or having looked, misunderstand what they are seeing.

Continue reading

Create Database-Driven Sites the Easy Way with GoLive 6

PHP/MySQL for the rest of us!
(originally published Spring, 2002)

Intro:
Designers now have a new tool to help them create php/mySQL-based
dynamic sites using without a steep learning curve. It is now
almost as easy to create a simple database-driven site as an html-based
one. Adobe’s GoLive 6 has improved their dynamic link module and
completely integrated it into the application. It now includes
php/mySQL support and plenty of help and templates for creating
your first database-driven website.

  • Why make a dynamic
    site?
  • Getting
    started.
  • How to talk
    to MySQL without a Ph.D.
  • Setting
    up the site in GoLive.
  • Adding Dynamic
    Content to your page.
  • Continue reading

    Installing PHP/mySQL scripts – Tips for Designers

    or …
    “Just Enough about Unix to get into trouble…”

    Determine type of server:
    I’ve found that PHP scripts work more reliably on Unix servers than NT. Also, be sure that the server is not running PHP as a cgi script. It really doesn’t work as well. How do you tell?

    phpinfo
    Upload a little file containing this code:

    <? phpinfo(); ?>

    Name the file “phpinfo.php” and then view that page online in your web browser. This is a php script that returns all the information about your server environment. In the first table of information, you will find “Server API.” This should be “Apache.” If it says “CGI” you are in trouble. However some things will work fine in this setup, so it’s always worth a try.

    Continue reading