counter
Currently browsing Code Snips


Articles on Code Snips

PHP AJAX CHAT updates text run-off problem

Tags: , , — Hawk on May 13, 2008 at 6:06 am

As one of my audience so nicely pointed out we have a text run-over problem.  These are generally easy to fix, I tend to use a three prong approach.  For me I felt 30 characters was a good length.

First run

ALTER TABLE `chatbox` CHANGE `message` `message` VARCHAR( 30 )

This will fix it at the database level, but we don’t want it to even get that far so next we change the maxlength of the input. (more…)

PHP Pentago, Determine Winner, Win State algorithm

Tags: , , — Hawk on May 11, 2008 at 4:36 am

Pentago is a great strategy game and certainly fun to play. Basically it’s played on a 6×6 grid that is made up of 4 3×3 quadrants that can rotate once after each turn. The idea behind the game is to get five marbles in a row. Building an interface should be fun but for those just interested in the algorithm to determine a win state for Pentago in php.

(more…)


Palindrome PHP test

Tags: , — Hawk on April 23, 2008 at 6:43 pm

I tend to post regularly on some forums around the area and today I saw a fun little question, how to test for palindromes. If you aren’t familiar with Palindromes they come from biology DNA sequences that are complimentary. However most people know them as words that read the same forward and backwords like “straw warts” or “santa at nas”. I took about 5 minutes and wrote this nice little bit of code available below.

Palindrome Test

(more…)

PHP AJAX CHAT, Bug fixes - including weird mozilla bug

Tags: , , — Hawk on April 22, 2008 at 9:24 pm

Hello all. When I released PHP AJAX chat I knew that there was a problem with a few of the build of Firefox that didn’t like having SetTimeouts() outside of functions and requestobjects opening without full parameters. Well I have now fixed that and here is the patch. To install the patch do the following.

  1. Open up index.php oh php ajax chat archive
  2. find where this line is <script type=”text/javascript”> in mine it’s around line 33 and also find the end </script> which is around line 99.
  3. Hilight this area and replace it with the following code (more…)


Page 1 of 41234»