Archive for April 12th, 2010


Tips bersihin perhiasan perak

Kalau anda punya perhiasan perak dan warnanya sudah berubah kehitaman jangan kuatir. Anda bisa membersihkannya dengan menggunakan pasta gigi merk apa saja. Cara membersihkan nya bisa dengan menggunakan sikat gigi yang sudah tidak dipakai. Lakukan secara berkala supaya warna perhiasan perak anda tetap mengkilap. Selamat mencoba :d.

Suara hati

suara hati..


$conn = mysql_connect('localhost','dbusername','dbpassword') or trigger_error("SQL", E_USER_ERROR);
$db = mysql_select_db('dbname',$conn) or trigger_error("SQL", E_USER_ERROR);

for ($x = 0; $x < 106; $x++) {
   $number = rand(100,999);
   $sql = "INSERT INTO numbers (number, id) VALUES ($number, '')";
   $query = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR);
}

Bursa Efek

Bursa Efek Indonesia mengalami transisi pada tanggal 1 Desember 2007. Dengan bergabungnya Bursa Efek Surabaya dan Bursa Efek Jakarta maka pasar modal dilakukan secara nasional dan berubah nama menjadi Bursa Efek Indonesia. Bursa Efek Indonesia (Indonesia Stock Exchange) memfasilitasi perdagangan saham (equity), surat utang (fixed income), maupun perdagangan derivatif (derivative instruments). Hadirnya bursa tunggal ini diharapkan akan meningkatkan efisiensi industri pasar modal di Indonesia dan menambah daya tarik untuk berinvestasi. Situs tunggal Bursa Efek Indonesia dapat diakses melalui www.bei.co.id.

Pickled cucumbers

1 medium cucumber
10 small chili
1 small carrot
2 small red onion
5 tsp sugar
1/5 tsp vinegar

First wash cucumber, chili, carrot and red onion. Then peel and cut cucumber about 1″, don’t forget to clean the seed. Mix with cuts of carrot, red onion, chili, sugar and vinegar in pan. Taste, if enough put the pickles into bowl. Top with more pickles if you desire in to your food like fried rice, spaghetti or others you like. This salad makes your food more delicious, try it.

Dizziness

Dizziness refers to an impairment in spatial perception and stability. It is considered imprecise. It can be used to mean vertigo, presyncope, disequilibrium, or for a non-specific feeling such as giddiness or foolishness.

  • Vertigo: is a specific medical term used to describe the sensation of spinning or having one’s surroundings spin about them. Many people find vertigo very disturbing and often report associated nausea and vomiting. It represents about 25% of cases of dizziness.
  • Disequilibrium is the sensation of being off balance, and is most often characterized by frequent falls in a specific direction. This condition is not often associated with nausea or vomiting.
  • Presyncope is lightheadedness, muscular weakness and feeling faint as opposed to a syncope, which is actually fainting.
  • Non-specific dizziness is often psychiatric in origin. It is a diagnosis of exclusion and can sometimes be brought about by hyperventilation.

A stroke is the cause of isolated dizziness in 0.7% of people who present to the emergency room.

MVC

MVC is a design pattern used by applications that need the ability to
maintain multiple views of the same data. The MVC pattern has been separated into Models for maintaining data, Views for displaying data and Controller for handling events that affect the model or view. Hmm sound interesting design pattern.

And the CodeIgniter is an MVC framework for PHP. In CodeIgniter we could separates application logic from presentation. It will be easier for programmers to modify and develop the system in the future.
As we can see in CodeIgniter User Guide, with MVC permits your web pages to contain minimal scripting since the presentation is separate from the PHP scripting.

  • The Model represents your data structures. Typically your model classes will contain functions that help you retrieve, insert, and update information in your database
  • The View is the information that is being presented to a user. A View will normally be a web page, but in CodeIgniter, a view can also be a page fragment like a header or footer. It can also be an RSS page, or any other type of “page”
  • The Controller serves as an intermediary between the Model, the View, and any other resources needed to process the HTTP request and generate a web page.

Even CodeIgniter has complexity separation, you still can build your application minimally using Controllers and Views. And of course CodeIgniter also enables you to incorporate your own existing scripts, or even develop core libraries for the system, so you work as you need.
It is a glance about MVC and CodeIgniter, Interest to try :) .

Between work and hobbies

Sometimes we say that someone we know is “A square peg in a round hole”. This simply means that the person we are talking about is not suited for the job he is doing. He may be a doctor who really wants to be an singer or a engineer who likes acting. And many peoples are “square pegs” around us. As a result they probably are not doing a very good job and certainly they are not happy. But they are some who happy in this situation.

There is popular saying in the United States and also other countries “All work and no play makes Jack a dull boy”. We cannot work all the time if were are going to maintain good health and enjoy life. But everyone has his own perception. Perhaps the most popular way is we appropriate work hobby.

Connecting to MySQL with PHP

To connecting MySQL Database, make sure you have MySQL running at a location to which your Web server can connect. Then you have created a user, password and the database to which you want to connect. The mysql_connect() is the first function in PHP to connect to MySQL.
The basic syntax for the connection is:

 mysql_connect("hostname", "username", "password");

Using actual sample values, the connection function looks like this:

 mysql_connect("localhost", "root", "pass");

This function returns a connection index (connection is succesful) or return false (connection fails). Lets see a working example of a connection script below. It assign the value of the connection index to a variable called $conn, then prints the value of $conn as proff of a connection. If you are not using password, just empty the password variable.

<?php
$host="localhost";
$user="root";
$pass="";
$conn=mysql_connect($host, $user, $pass);
echo "$conn";
//eof

Save this script as config.php (sometimes I save as config.inc), then place it on your work folder. Check the result on your web browser and you will see something like this:

 Resource id #2

Connecting to MySQL using the mysql_connect() function is pretty straightforward. The connection closes when the script finishes its execution, but if you would like to explicitly close the connection, simply add the mysql_close() function at the end of the script.
And now we will try to connecting a Database, using function called mysql_select_db() with the following syntax:

 mysql_select_db($db,$conn);

To connect to a database named test_conn, first use mysql_connect(), then use mysql_select_db(), like this:

<?php
$host="localhost";
$user="root";
$pass="";
$db="test_conn";
$conn=mysql_connect($host, $user, $pass);
mysql_select_db($db,$conn);
//eof

You can modified simple connection script above by adding error message. The mysql_error() function will return a helpful error message when there is a mistake. Don’t forget to insert conjunction with the PHP die() function. See the modified script below:

<?php
  $host="localhost";
  $user="root";
  $pass="";
  $db="test_conn";
  $conn=mysql_connect($host, $user, $pass);
   if (!$conn){
       die('Could not connect Database.'.mysql_error());
   }
   mysql_select_db($db,$conn);
//eof

Move on to the next section to start inserting data into your table, and soon you’ll be retrieving and formatting it via PHP. Good Luck.

Powered by WordPress.