The random image rotator uses PHP to get a list of images in a specified directory. This listing is then used in combination with the JavaScript Rotate Images code and its Random Rotation component to randomly swap in these images on a timer. You can specify whether to include all the directory's images or limit the number.
source here
and an example can be found here http://www.hanslips.com/
Monday, 7 April 2008
php to pull down rss feeds with cURL
Here is three lines of PHP to pull down RSS feeds:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,
'http://www.somewebsite.com');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$contents = curl_exec ($ch);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,
'http://www.somewebsite.com');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$contents = curl_exec ($ch);
Wednesday, 2 April 2008
mysql command for creating a primary index
here is a mysql command for creating a primary index for a table:
id INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT
id INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT
php function to submit values to a form
Here is a php function to submit values to a form:
function hitForm($loginURL, $loginFields, $referer=”") {
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, “cookies.txt”);
curl_setopt($ch, CURLOPT_COOKIEFILE, “cookies.txt”);
curl_setopt($ch, CURLOPT_URL, $loginURL);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_REFERER, $referer);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $loginFields);
$ret = curl_exec($ch);
curl_close($ch);
return $ret;
}
hitForm(”http://technorati.com/login.php”, “username=wagerank&password=%pass%”);
You can read the original here
function hitForm($loginURL, $loginFields, $referer=”") {
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, “cookies.txt”);
curl_setopt($ch, CURLOPT_COOKIEFILE, “cookies.txt”);
curl_setopt($ch, CURLOPT_URL, $loginURL);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_REFERER, $referer);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $loginFields);
$ret = curl_exec($ch);
curl_close($ch);
return $ret;
}
hitForm(”http://technorati.com/login.php”, “username=wagerank&password=%pass%”);
You can read the original here
Sunday, 30 March 2008
inserting text into a database in php
I am using addslashes() and stripslases() to keep the dirty data out and stop the php from erroring out
Wednesday, 26 March 2008
foreign keys on a compound primary key
Here is the MYSQL command to create a compound primary key from two foreign keys:
create table loc_title(lid int(11) not null, tid mediumint(9), tag text, FOREIGN KEY(lid) REFERENCES location(lid) ON DELETE CASCADE, FOREIGN KEY(tid) REFERENCES title(tid) ON DELETE CASCADE, PRIMARY KEY(lid,tid));
create table loc_title(lid int(11) not null, tid mediumint(9), tag text, FOREIGN KEY(lid) REFERENCES location(lid) ON DELETE CASCADE, FOREIGN KEY(tid) REFERENCES title(tid) ON DELETE CASCADE, PRIMARY KEY(lid,tid));
Thursday, 13 March 2008
safari javascript bug work around - selectbox.options.add
I found a work around for the old safari bug selectbox.options.add when I replaced it with this: selectbox.options[selectbox.options.length] = new Option(optn.text,optn.value);
Subscribe to:
Posts (Atom)