evilprofessorDesigns
Getting you the website you need...
Evilprofessor Designs the home of affordable web site design
Quick inexpensive open source websites through to full bespoke web applications...
Evilprofessor Designs
Here at Evilprofessor Designs we encourage the research into new technologies and learn how to use them in new and interesting ways. We also encourage the writing of short articles to share the knowledge gained with other people in the web development community.
Stuck on 4096 characters???
26 Oct 2007
The first load would go through fine and all images and their links would appear as I’d expect. There was also no problems in IE7, Safari (on Windows), or Opera 9+. When it came to Firefox 2 the image list would be cut short! Editing the javascript it basically seems that the returned data would be cut off at 4096 characters.
It took a while to track down the result. I thought initially this might of been a javascript maximum string length problem, but that other browsers just let the issue slip. Not that either. Anyway it turns out that text nodes are split at 4096 characters.
It’s quite simple to fix you simply need to normalise() your returned data in your AJAX script. Simply add the second line once you’ve gathered your XML data:
xmlResponse = xmlHttp.responseXML;
xmlResponse.normalize();
This will solve the 4096 character limit when using Firefox 2 or any other browser I haven’t checked that doesn’t normalise the data automatically.
Quick and easy $_POST security…
25 Oct 2007
$sql = "insert into table set ";
foreach ($_POST as $key => $data)
{
$sql .= $key." = '".strip_tags(htmlentities(addslashes($data)))."',";
}
$sql .= mysql_query(rtrim($sql,',').";") or die(mysql_error());
What this script does is to take your $_POST data and remove anything malicious from it. Looping over the $_POST data we build up an SQL statement. At the end then we simply execute using with mysql_query.
NOTE: This does not validate your data, it just helps prevent malicious attacks.
Another version of this that I use to to grab all my form information into variables to to place the following code within the foreach loop instead…
eval("$".$key." = '".strip_tags(htmlentities(addslashes($data)))."';");
This makes up a list of variables following your forms field names and strips malicious code from them. This method then allows you to do some form validation before inserting data into your tables 
Including an RSS Feed on your site…
26 Sep 2007
Basically I use my RSS script to generate news feeds for the sites that I write. Examples can be seen on these sites,
But generally you can use the feed generator to serve any information you wish. For example would be the results of a search query where the query variables can be picked up from $_GET[]’s $_POST[]’s.
Anyway a question a friend asked me was “What’s the Point in RSS” good question! Click on the link to find out 
Right anyway onto the script. Firstly we need to tell the browser or news-aggregator that it’s looking at a rss:xml feed,
-
// Write the RSS header
It’s at this point that I usually set up my database connection and link to the information I require so usually it’ll be something like,
-
include_once( "./connect.php" );
I limit to 50 as no one wants to see 1000’s of posts going back years and years unless they specifically ask for it
Then we start writing out the ‘introduction’ part of the feed,
Then we loop through our items (in this case news articles) printing the data out to our xml file,
-
// loop through the array pulling database fields for each item
-
{
-
$title = textFormat($newsItem[‘news_title’]);
-
$link = $_SERVER[‘HTTP_SERVER’]."news.php#news".$newsItem[‘id’];
-
$description = textFormat($newsItem[‘news_item’]);
-
$uid = "tag:".$_SERVER[‘HTTP_SERVER’].",2007-09-26:rss.".$newsItem[‘id’];
-
echo "<item></item>";
-
echo "";
-
echo "
-
<pubdate>".$pubDate."</pubdate>";
-
echo "";
-
}
Remember for our RSS feed all text should be UTF-8 encoded so we include a little function to do this,
Then it’s just a simple case of closing down our xml tree and we’re all done,
-
echo "";
Pretty painless wasn’t it
And you can use these feeds to output anything of use. If someone is returning to your site to check for updated information should it be course dates, news items, forum posts, blog entries, even property searches it can all be done using RSS feeds.
-
<!—->//==========================================
-
// Author: Steven Lloyd Watkin
-
// Company: Evilprofessor Designs
-
// Website: http://www.ep-projects.co.uk
-
// Date: June 2007
-
// Feel free to use and modify, but please
-
// include reference to my site somewhere
-
//==========================================
-
-
-
echo "<!–l version=\"1.0\" encoding=\"utf-8\"–>";
-
echo "<channel></channel>";
-
-
// retrieve database records
-
include(‘connect.php’);
-
-
echo "";
-
echo "<description>YOUR SITE/FEED DESCRIPTION</description>";
-
-
// loop through the array pulling database fields for each item
-
{
-
$title = textFormat($newsItem[‘news_title’]);
-
$link = $_SERVER[‘HTTP_SERVER’]."news.php#news".$newsItem[‘id’];
-
$description = textFormat($newsItem[‘news_item’]);
-
$uid = "tag:".$_SERVER[‘HTTP_SERVER’].",2007-09-26:rss.".$newsItem[‘id’];
-
echo "<item></item>";
-
echo "";
-
echo "";
-
}
-
echo "";
-
?>
Latest News
- We have just completed work on the new keyfinder website. See our updated portfolio for further details and to visit the site.
- We have been asked to add a new comments system the Cardiff Scuba site. Please see the course comments system.
- We have just finished our latest site DiveSigns.com please take a look.
- We are concentrating on AJAX applications some examples on Evilprofessor.co.uk soon!

Web Standards
Evilprofessor Designs makes a huge effort to make sure all websites conform to web standards set out by the W3C. This not only ensures that your web pages look consistently good in the vast majority of browsers, but that they are compatable with future standards of web design, and still display clearly on older internet browsers.
Best technolgies
We make use of the best technologies to ensure that your site runs quickly and efficiently and displays the correct information for your customers. Evilprofessor Designs work primarily with PHP and mySQL but if you have a current site written in another language (e.g. ASP) we have experience in many other technologies. Currently we are training in AJAX and other so called Web 2.0 technologies. We are also familiar with several open source web solutions (such as Zen Cart, OSCommerce, Wordpress, etc) which means we can provide you with powerful websites with the minimum of cost and time.