24 Sep, 2003
Posted by: Jennifer In: Bookmarks
I've developed another email address encoding function in PHP. This works on a similar principle to the well-known HiveWare javascript encoder, but doesn't require javascript to be enabled on the client. Instead, this PHP function just needs to be included in your web page, and then where it is called it will write out an encoded version of your mailto link. The CDT; has reported that encoded email addresses have been effective in preventing spambots from finding addresses on your web site. The function is provided and described on my web site: PHP Email address encoder.
Comments Off on PHP Email Address Encoding Function
24 Sep, 2003
Posted by: Jennifer In: Bookmarks
One thing I've found myself having to dig for are the links to the actual templates for RSS feeds… so here we go.
Here's Christine's scripty post about why you need an RSS feed and what it is. (NOW!) 😉
This is Dive Into Mark's basic template (When you click that link, it looks all funky in the browser, you have to view source to see the code you need… So I just posted it below…) (Dive into Mark's full post here)
Here's Jennifer's template (which is my favorite because it's full post, and comments!)
I know people have other templates out there, so here's your chance to post them. (If you're posting the actual template in the comments – which would be GREAT – so I don't have to hunt for them, or bang my head against the wall when you rename all your pages and I can't find your templates any more) – just don't forget to use the "decoder" link to change all the < to < and > to >
Read the rest of this entry »
All details are on the PHP site (but just the highlights because I seem to need it a lot):
$_FILES['userfile']['name']
The original name of the file on the client machine.
$_FILES['userfile']['type']
The mime type of the file, if the browser provided this information. An example would be "image/gif".
$_FILES['userfile']['size']
The size, in bytes, of the uploaded file.
$_FILES['userfile']['tmp_name']
The temporary filename of the file in which the uploaded file was stored on the server.
$_FILES['userfile']['error']
The error code associated with this file upload. ['error'] was added in PHP 4.2.0
Comments Off on PHP: Anatomy of a file upload
The point of this script-snippet is so you can set up two hierarchies of categories. So there's a main category, and a few "sub-categories" below it. An example of this is on Christine's Pixelog site, on her album page.
This differs from the way MT has "Primary" and "Secondary" categories in that in mine, the sub-categories for a main category, can only be a sub category of that one main category – not any other main category. Here's another example: Ohnozone.net . In the sidebar, scroll down to the "categories", You'll see there's a main category "Appearances", and there's sub categories beneath it. "Interviews & Articles" and "TV"
Read the rest of this entry »
I use this almost on a daily basis, and yet I can't commit it to memory. So I don't have to go searching for it each time I need to write it…
$databaseName = "YOURDATABASENAME";
$dbconnection = mysql_connect("localhost", "DATABASE-USERNAME", "DATABASE-PASSWORD") or
die ('I can?t connect to the database.');
mysql_select_db($databaseName,$dbconnection);
$value = "SOMEVALUE";
$query = sprintf("SELECT FIELDNAME from TABLENAME where FIELDNAME='%s';", $value);
$result = mysql_query($query);
$totalNum = mysql_num_rows($result);
while ($row = mysql_fetch_array($result)) {
echo $row['FIELDNAME'];
}
////////OR//////
for ($i =0; $i < $totalNum; $i++) {
$row = mysql_fetch_array($result);
echo $row['FIELDNAME'];
}
15 Sep, 2003
Posted by: Jennifer In: Bookmarks
Comments Off on PHP and CSS tutorials (and more) from Macromedia
12 Sep, 2003
Posted by: Jennifer In: Bookmarks
Recently I decided to stop using Live Journal and decided to move all my writing, comments, and links to my own website. Previously, I had just linked to my journal at the LJ site, but I needed a way to convert my old LJ content to MT.
Read the rest of this entry »
09 Sep, 2003
Posted by: Jennifer In: Bookmarks
Just wanted to store some code I use a lot and am tired of looking up 😉
In some of the scripts I work on, I create a field for a timestamp. For that field I insert the PHP value: time()
When recalling that value, it's just an ugly looking UNIX timestamp, so to format it to something nice, I do the following: (as posted on the PHP manual)
<?php
/*
Assuming the UNIX timestap was for : March 10th, 2001, 5:16:18 pm
and you already did a mysql query, and fetch_array
and the name of the field for timestamp, is 'timestamp'
*/
$today = date("F j, Y, g:i a", $row['timestamp']);
// March 10, 2001, 5:16 pm
$today = date("m.d.y", $row['timestamp']);
// 03.10.01
$today = date("Ymd", $row['timestamp']);
// 20010310
$today = date('\i\t \i\s \t\h\e jS \d\a\y.', $row['timestamp']);
// It is the 10th day.
$today = date("D M j G:i:s T Y", $row['timestamp']);
// Sat Mar 10 15:16:08 MST 2001
?>
Comments Off on Date Time