Swordtail fish

Pet 32 Comments »

Long time didn’t take care of my aquarium. now no nice fish inside. so must do some research then start importing some new nice pretty fish in my aquarium. 🙂

Male Swordtail Female Swordtail

Common name: Swordtail
Origin: Southern Mexico and Guatemala
Maximum size: 4" or about 10cm (including tail)
Minimum Tank Size: Around 10-15 US gallons

Care:
An easy fish for beginners. Needs a temp. of 72-73*F (22-23* C.) Enjoy well-planted aquariums with plenty of room for swimming. They live in loosely grouped schools. Usually Keep 1 male for every 2 females. These fish come in a variety of colors as many other livebearers do. Some varieties include the oringinal wild-type which has olive-green backs, greenish-yellow sides, yellow belly, and a red band. There are also lyretail swords and Hi-fin swordtail varieties. They should be housed with other peaceful community fish such as other livebearers, tetra, plecostomus, among many others.
Read the rest of this entry »

Joss Stone is world’s best celebrity dog owner

My Life, Pet No Comments »

When it comes to celebrity dog-parenting skills, Joss Stone is tops and Paris Hilton is the worst, according to an online poll of readers of two dog magazines.

Stone, who has a poodle named Dusty Springfield, volunteered for the North Shore Animal League America after seeing images of pets stranded in the aftermath of hurricanes Katrina and Wilma, said The New York Dog and The Hollywood Dog magazines, which conducted the poll.

The 18-year-old British singer also recorded a public service announcement seeking support for the homeless pets of the Gulf Coast.

Paris Hilton with doggy Hilton, a 24-year-old hotel heiress and star of "The Simple Life," was voted the world’s worst celebrity dog owner. (LOL)

Source: Dallas Morning News

PHP Tutorial: Guestbook for beginner

News No Comments »
I’m writting this php tutorial specially to all my fellow friends who wish to learn php but do not know where to start. Hope after this simple tutorial, you all will have a better understanding towards php. Below is the tutorial to develop a guestbook system. U might ask me why teach you all to write a guestbook system where guestbook almost dissappear on the internet. The answer is I want you all to learn the basic of php and i guestbook system is simple and good enough to demostrate all the commonly used php function.

This is just a tutorial, there are still having some security vulnerabilities.
DO NOT USE THESE SCRIPT FOR PRODUCTION PURPOSES!

Before i start i assume you all already has the WAMP or LAMP environment to test out the script. If you do not have PHP and MySQL install in your PC, you might want to take a look at my previous post "How to install AMP (apache, mysql and php) in window xp".

Let’s start:-

Before we start our code we need to design what we want our user to enter and how the data to be store in the database. For a basic guestbook it should allow user to enter their fullname, email, website and comments. So based on all this fields we come out with the table structure as below.

CREATE TABLE guestbook (
    id int(7) not null primary key auto_increment,
    fullname varchar(50) not null,
    email varchar(100),
    website varchar(100),
    comment text not null,
    created datetime not null
)

As you go thru the code, you will notice that ‘id’ and created are not mention earlier but now it’s included in our table structure. And, ‘id’ has been mark as the primary key here where it helps to identify each and every comment that visitor submit uniquely. Everytime user submit their comment we will create a new id for their comment at the same time we also save the date and time they submit their comment in ‘created’ field.

Copy and paste the code above and execute it in your mysql database. Once this script is executed, you will see a new table named ‘guestbook’ created

Ok now the database structure is ready, we can start our code now:-
First we need a form for user to key in their comment:-
Save this file as index.php

<html>
<head>
<title>Guestbook system</title>
</head>
<body>

<?php
    require_once(‘class.guestbook.php’);
    $g = new GuestBook();
   
    if($_POST[‘action‘] == ‘Submit‘) {
        // if user press on Submit button it will capture user input
        // and save into database table

        $g -> fullname = $_POST[‘fullname‘];
        $g -> email = $_POST[‘email‘];
        $g -> website = $_POST[‘website‘];
        $g -> comments = $_POST[‘comments‘];
        if(!$msg = $g -> save()) {
            $msg = ‘Your comment has been added successfully‘;
        }
        $msg .= ‘<br><br>‘;
    }

    $comments = $g -> getAllComments();
   
    if(!empty($comments)) {
        foreach($comments as $i => $val) {
            $content .= ‘<div style="border:1px solid #cccccc; background-color:#EBEBC2;">‘;
            $content .= $val[‘fullname‘] . ‘‘ . date(‘d M Y H:i‘, strtotime($val[‘created‘])) . ‘<br>‘;
            $content .= $val[‘email‘] . ‘<br>‘;
            $content .= $val[‘website‘] . ‘<br>‘;
            $content .= $val[‘comment‘] . ‘<br>‘;
            $content .= ‘</div><br>‘;
        }
    } else {
        $content = ‘No record in your guestbook.’;
    }
    echo $msg;
    echo $content;
?>
<form name="form1" method="post" action="">
  Name:  <input type="text" name="fullname">
  <br>
  Email:  <input type="text" name="email">
  <br>
  Website:  <input type="text" name="website">
  <br>
  Comments:<br>  <textarea name="comments" cols="30" rows="5"></textarea><br>
  <input type="submit" name="action" value="Submit">
</form>
</body>
</html>

Then we will developed a class to store and retrieve all the data to and from the database.
replace your mysql_user and mysql_password with your username and password.
class.guestbook.php

<?php
    class GuestBook {
        var $id;
        var $fullname;
        var $email;
        var $website;
        var $comments;
        var $created;
       
        var $conn;
        var $query;
       
        function GuestBook() {
            $this -> conn = mysql_connect(‘localhost’, ‘mysql_user’, ‘mysql_password’) or die (‘Error: Could not connect to mysql server’);
            mysql_select_db(‘yourdatabase’, $this -> conn) or die (‘Error: Could not select db’);
        }
       
        function save() {
            if(!empty($this -> fullname) && !empty($this -> comments)) {
                $sql = "INSERT INTO guestbook (fullname, email, website, comment, created) VALUES (‘". $this -> fullname . "’, ‘" . $this -> email . "’, ‘" . $this -> website . "’, ‘" . $this -> comments . "’, ‘" . date(‘Y-m-d H:i:s’) . "’)";
                if(!$query = mysql_query($sql, $this -> conn)) {
                    return ‘Error, could not insert comment.<br>MySQL Error: ‘ . mysql_error();
                }
               
            } else {
                return ‘Error, paramenter is empty!’;
            }
        }
       
        function getAllComments() {
            $sql = ‘SELECT * FROM guestbook’;
            $query = mysql_query($sql);
           
            $i = 0;
            while($row = mysql_fetch_assoc($query)) {
                $ret[$i] = $row;
                $i++;
            }
           
            return $ret;
        }
    }
?>

After you create this 2 files and save in your web server root folder, you are basically done. Guestbook system is ready now. Open up your browser and enter http://localhost/yourdirectory/index.php and you can start to use the system.

I’ll explain the inside code next time. At this moment, try to go thru the code, i think it’s quite simple and easy to understand. I’ll post the code explaination next time. 🙂

WP Theme
Entries RSS Comments RSS Log in