Saturday, 9 August 2008
Monday, 21 April 2008
http://centricle.com/tools/html-entities/
The previous post used: http://centricle.com/tools/html-entities/ to search and replace the open tag brackets
How to use Google Translate to offer your website in different languages
Here is the form details to submit to Google translate, you need to replace the image source in the text below:
<form action="http://www.google.com/translate" >
<script language="JavaScript">
<!--
document.write ("<input name=u value="+location.href+" type=hidden>")
// -->
</script>
<input name="hl" value="en" type="hidden">
<input name="ie" value="UTF8" type="hidden">
<input name="langpair" value="" type="hidden">
<input name="langpair" value="en|fr" title="French" src= "images/flags/fr.png" onclick="this.form.langpair.value=this.value" type="image">
<input name="langpair" value="en|de" title="German" src= "images/flags/de.png" onclick="this.form.langpair.value=this.value" type="image">
<input name="langpair" value="en|it" title="Italian" src= "images/flags/it.png" onclick="this.form.langpair.value=this.value" type="image">
<input name="langpair" value="en|pt" title="Portuguese" src= "images/flags/pt.png" onclick="this.form.langpair.value=this.value" type="image">
<input name="langpair" value="en|es" title="Spanish" src= "images/flags/es.png" onclick="this.form.langpair.value=this.value" type="image">
<input name="langpair" value="en|ja" title="Japanese" src= "images/flags/jp.png" onclick="this.form.langpair.value=this.value" type="image">
<input name="langpair" value="en|ko" title="Korean" src= "images/flags/kr.png" onclick="this.form.langpair.value=this.value" type="image">
<input name="langpair" value="en|zh-CN" title="Chinese Simplified" src= "images/flags/cn.png" onclick="this.form.langpair.value=this.value" type="image">
<input name="langpair2" value="en|ar" title="Arabic" src= "images/flags/sa.png" onclick="this.form.langpair.value=this.value" type="image" />
</form>
<form action="http://www.google.com/translate" >
<script language="JavaScript">
<!--
document.write ("<input name=u value="+location.href+" type=hidden>")
// -->
</script>
<input name="hl" value="en" type="hidden">
<input name="ie" value="UTF8" type="hidden">
<input name="langpair" value="" type="hidden">
<input name="langpair" value="en|fr" title="French" src= "images/flags/fr.png" onclick="this.form.langpair.value=this.value" type="image">
<input name="langpair" value="en|de" title="German" src= "images/flags/de.png" onclick="this.form.langpair.value=this.value" type="image">
<input name="langpair" value="en|it" title="Italian" src= "images/flags/it.png" onclick="this.form.langpair.value=this.value" type="image">
<input name="langpair" value="en|pt" title="Portuguese" src= "images/flags/pt.png" onclick="this.form.langpair.value=this.value" type="image">
<input name="langpair" value="en|es" title="Spanish" src= "images/flags/es.png" onclick="this.form.langpair.value=this.value" type="image">
<input name="langpair" value="en|ja" title="Japanese" src= "images/flags/jp.png" onclick="this.form.langpair.value=this.value" type="image">
<input name="langpair" value="en|ko" title="Korean" src= "images/flags/kr.png" onclick="this.form.langpair.value=this.value" type="image">
<input name="langpair" value="en|zh-CN" title="Chinese Simplified" src= "images/flags/cn.png" onclick="this.form.langpair.value=this.value" type="image">
<input name="langpair2" value="en|ar" title="Arabic" src= "images/flags/sa.png" onclick="this.form.langpair.value=this.value" type="image" />
</form>
Friday, 18 April 2008
Foreign Keys in Mysql
Here is a MYSQL statement to insert Foreign Keys:
create table table1(lid int(11) not null, tid mediumint(9), tag text, FOREIGN KEY(lid) REFERENCES table2(lid) ON DELETE CASCADE, FOREIGN KEY(tid) REFERENCES table3(tid) ON DELETE CASCADE, PRIMARY KEY(lid,tid));
create table table1(lid int(11) not null, tid mediumint(9), tag text, FOREIGN KEY(lid) REFERENCES table2(lid) ON DELETE CASCADE, FOREIGN KEY(tid) REFERENCES table3(tid) ON DELETE CASCADE, PRIMARY KEY(lid,tid));
mysql privileges to only one database rather than global
Here is the Mysql command for database specific user privileges rather than global:
grant all on database.* to 'user'@'localhost' identified by 'password';
grant all on database.* to 'user'@'localhost' identified by 'password';
Friday, 11 April 2008
print HTML block inside code
Here is an old classic for printing HTML block inside PHP:
$html = <<< EOH
EOH;
echo($html);
$html = <<< EOH
EOH;
echo($html);
Tuesday, 8 April 2008
Monday, 7 April 2008
php and Javascript to rotate an image
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/
source here
and an example can be found here http://www.hanslips.com/
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);
Friday, 29 February 2008
Pesky Joomla component table
I found a fix for that spacing problem in the Joomla template where a component table is added "contentpaneopen" and it can add cellpadding and cellspacing to your template, this can be removed by editing components/com_content/content.html.php
Wednesday, 27 February 2008
getting HTML pages to parse PHP
By adding this to my .htaccess file:
AddType application/x-httpd-php .php .html
I got my Browser to pick up my PHP includes in my HTML files
AddType application/x-httpd-php .php .html
I got my Browser to pick up my PHP includes in my HTML files
Monday, 25 February 2008
still having problems with CSS in IE 7
Am still being forced to split out my CSS to take care of CSS in IE 7 for Joomla, which forces me to have a file I cannot edit from the CMS:
[if lte IE 6]
[if IE 7]
[if lte IE 6]
[if IE 7]
Cpanel email quota - error reads "invalid maildirsize file"
I was having trouble with setting new quotas for mail directories in Cpanel, when I found that you can delete the text file that holds the quota information and it will re-create itself. This will get rid of any corruption/confusion that has caused the quota error, but make sure you delete the 'maildirsize' file for that user only.
Subscribe to:
Posts (Atom)