2:34 PM

Adware-alexa? There is Adware in the Alexa toolbar

posted under by FR3@K | Edit This
At least, that is what my virus scanner told me.

Today I was wanting to be a “regular reader” to some of my sites, so I switched back to Internet Explorer, and I got myself equipped with the Google Toolbar and Alexa Toolbar.

I didn’t have these installed on Firefox, because the SearchStatus add-on could help me tell the Google PageRank and Alexa Traffic Rankings of the sites (which is essentially what I need for each of the toolbars).

To my horror, when I tried to install the Alexa Toolbar, my virus scanner told me that the toolbar comes with Adware!

Now, tell me. Which should I believe - the virus scanner, or Alexa?

I guess I won’t take chances. Out you go, Alexa. I’ll stick to Firefox and SearchStatus. I’d browse happy.

Interestingly Alexa has a nice little box on the toolbar download page that goes like this:

My oh my… looks like something went wrong somewhere huh.

3:24 AM

PHP : Simple Login/Logout System with Sessions

posted under by FR3@K | Edit This
This tutorial will help you create a really basic user login system.

Here is what we are going to do in English: The user can login with an email & password. If the email and password match then create a session and allow the user to access the private members page. If an unauthorized user tries to access the members page without logging in, they will be forced to return to the login page.

So lets start off by creating a new database to store emails and password.

CREATE DATABASE test;

Next we can create a table in the database to store the users email and password. If you can’t figure out how to create the database and table, I recommend Googling for some general MySQL & PHPMyAdmin tutorials. They will help you a lot.

CREATE TABLE usersystem
(
id int AUTO_INCREMENT NOT NULL,
email varchar(120) NOT NULL,
password varchar(30) NOT NULL,
PRIMARY KEY (id)

);


INSERT INTO usersystem(email,password)
VALUES ('test@brendewilson.com','123');


INSERT INTO `usersystem` (email,password)
VALUES ('anothertest@brendenwilson.com','1234');

If the SQL code above was correctly entered into the ‘test’ database then you will have three columns in the database, ID, Email and password. The ID field is there to identify each entry as unique. Some people might have two accounts with the same email and if that happens, the ID field will allow us to differentiate between the two. The primary key part says that the ‘ID’ field will be unique for every row. The last two rows insert test data into the database so we can test the login system when it is finished.

Now create a file called include.php. This file will store all the code we want place at the top of every page.

<?php

session_start();



$host = "localhost";

$username = "USERNAME";

$password = "PASSWORD";

$db = "test";

@mysql_connect($host,$username,$password) or die ("error");

@mysql_select_db($db) or die("error");

?>



We are going to include this file at the very beginning of every page we setup. It will start the session and then connect your page with the MySQL database.

One thing to note: If you get an error saying that the headers were already sent, your start_session() probably wasn’t at the very top of the page. The start_session() has to be at the very top of the page.

Now create a login.php with this code.

<?php

require_once('include.php');

$error = '';

$form = $_POST['submit'];

$email = $_POST['email'];

$password = $_POST['password'];



if( isset($form) ) {



if( isset($email) && isset($password) && $email !== '' && $password !== '' ) {



$sql = mysql_query("SELECT * FROM `usersystem` WHERE email='$email' and
password='$password';");



if( mysql_num_rows($sql) != 0 ) { //success

$_SESSION['logged-in'] = true;

header('Location: members.php');

exit;

} else { $error = "Incorrect login info"; }

} else { $error = 'All information is not filled out correctly';}

}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Login</title>

</head>

<body>

<form action="<?php $PHP_SELF; ?>" method="post" >

Email<br />

<input name="email" type="text" value="<?php echo "$email";?>" /><br /><br />

Password<br />

<input name="password" type="password" /><br />

<input name="submit" type="submit" value="Log In" />

</form>

<?php

echo "<br /><span style=\"color:red\">$error</span>";

?>

</body>

</html>




Lets break this code down so it a little easier to understand.

In English, here is what the code means:
Include the include.php file.
Set the $error variable to a blank value.
If the form was submitted, put the values into the variables, $form, $email, $password so we can use them later.
If the form is submitted....
And the email and password fields are filled out and they aren't blank...
Check to see if there are any rows in the database that have a matching email and password.
If there are, that means the user entered a matching email and password.
Set the session.
Change the page to members.php.
And stop running the php code.
If the user didn't enter a matching email and password, throw an error.

Now create the members.php. This page will only be available to people who have signed in on the prior page. Here is the code that goes in that page.

<?php

require_once('include.php');

// is the one accessing this page logged in or not?

if ( !isset($_SESSION['logged-in']) || $_SESSION['logged-in'] !== true) {



// not logged in, move to login page

header('Location: login.php');

exit;

}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Freak's Blog</title>

</head>

<body>

Sweet you lgged in.

<a href="logout.php">logout</a>

</body>

</html>




This block of code is actually pretty simple. Just like on all the other pages, we include the include.php file at the top. The include.php file sets the session up and connects to the MySQL database. Then, if the appropriate session is not set (the user didn’t login), we move the user to the login page and exit the code. If the users has logged in, and their session is appropriately set, they will see the rest of the page. This pages format can be copied to create additional hidden pages.

Now to the final step. Create logout.php and enter this code:

<?php

session_start();

// if the user is logged in, unset the session

if (isset($_SESSION['logged-in'])) {

unset($_SESSION['logged-in']);

}

// now that the user is logged out,

// go to login page

header('Location: login.php');

?>




This page doesn’t have any HTML in it. The first line starts the session, and then if the user is logged in, the session will be destroyed and the user will be redirected to the login page.

I hope you enjoyed the tutorial. Please leave me feedback through the comment system below so I can improve my tutorials in the future.

3:22 AM

PHP : Set Cookie Function

posted under by FR3@K | Edit This
It's perhaps common knowledge these days as to what a cookie is. A cookie sits client-side in a user's browser and is sent to the server when the page is loaded. Cookies, however, can go a little deeper than just setting and receiving.

PHP Code:
setcookie('myCookie', 'TalkPHP.com', time() + 2592000);
The setcookie() function accepts a total of 7 arguments. The first 2 are the only mandatory arguments. The above code probably looks familiar - we give the cookie a name, give it a value and set its duration to 30 days. The 3rd argument, the time argument, will default to 0 if you leave it empty and thus the cookie will expire at the end of the session - typically when the user closes their browser.

The 4th argument in setcookie() is the cookie path. By default, if you leave this argument empty, it will set itself as the directory you are currently in. For instance, if I'm in the directory TalkPHP.com/members/ (this could be a mod-rewrite URL) then the cookie path will be /members/. What this means is that if I were to then navigate back to the index, that cookie I set would not be valid for the index and thus not be transferred to the server. In order to make the cookie available to the entire site, no matter which directory you happen to be in, you must specify the 4th argument like so:

PHP Code:
setcookie('myCookie', 'TalkPHP.com', time() + 2592000, '/');
The next argument along, number 5), is the domain argument. Again, this will default to the domain you are on. Many problems can arise with this argument, especially with www. and non-www. You see, setting the path to www.talkphp.com would make the cookie only available to the www sub-domain. Therefore if I omitted the www the cookie would not register. To get around this you can specify the 5th argument:

PHP Code:
setcookie('myCookie', 'TalkPHP.com', time() + 2592000, '/', '.talkphp.com');
Moving swiftly along to the next argument, the secure argument. This simply tells the browser whether or not to transfer the cookie only over a secure connection - HTTPS. If it is set to true then the cookie will only be transferred when the protocol being used is HTTPS and not the plain old HTTP. The default, however, is false which means that the cookie will be sent regardless of the protocol being used at the time. Now we have:

PHP Code:
setcookie('myCookie', 'TalkPHP.com', time() + 2592000, '/', '.talkphp.com', false);
Looking swish, eh? There is 1 last argument to mention and that is the 'HTTP only' argument. In a nutshell this means that the cookie will not be available by such scripting languages as Javascript. Therefore if we were to set it:

PHP Code:
setcookie('myCookie', 'TalkPHP.com', time() + 2592000, '/', '.talkphp.com', false, true);
Then using the following code would give us a blank alert box, since JavaScript will not be able to access the cookie information:

Code:

<script type="text/javascript">

alert(document.cookie);

</script>



This is truly awesome because it prevents a lot of XSS attacks! All modern day browsers will obey this rule - users still using ancient browsers may still be vulnerable but really that's their own fault for not hitting the oh so prominent update button.


That's all there is to the setcookie() function. Once we have set our cookie, PHP will automatically retrieve it and place it into the $_COOKIE superglobal variable, as well as the $_REQUEST superglobal variable.

3:14 AM

PHP Sessions and Cookies

posted under by FR3@K | Edit This
I'm going to teach you the basics of MySQL and showing the contents of a database table.

Read from here if you haven't got phpMyAdmin

first of all you'll have to create a database and a table of course
sorry for the ones who haven't got PHP MyAdmin, but hey don't be afraid register @ FreeSQL.org and you have it for free!

first for the ppl who haven't got PHP MyAdmin open the link and scroll down you'll see a form
enter the username, password, database name, and just a few numbers in the creation code. Below email adress should be MySQL selected, if not select it
then just submit. I don't know if you get an e-mail I think so.
okay after registration scroll up, and on the right you see Database Administration then just click phpMyAdmin enter your username and password and phpMyAdmin opens!

Let's get started

phpMyAdmin is open now
normally u see this now:

MySQL
Create a new database [Documentation]
and an input box

okay just enter the name you want and submit after you clicked the submit button u should see a text area that's where u have to enter the sql code:

Code:
CREATE TABLE `products` (
`id` INT( 8 ) NOT NULL AUTO_INCREMENT ,
`name` VARCHAR( 255 ) NOT NULL ,
`price` INT( 8 ) NOT NULL ,
PRIMARY KEY ( `id` )
);


okay let's explain
CREATE TABLE is obvious I think
`products` is the name of the table
`id` this is the number that belongs to the product
NOT NULL means this value must be filled in
AUTO_INCREMENT means that if you add a product with a form, the id number will increase automaticly with 1
`name` is just the name of the product
VARCHAR means 1 or more characters ( 225 ) is the maximum characters
NOT NULL is obvious I will not mention this anymore
`price` the price of the product
INT means only numbers no numbers with a , in it
so not �1,5 or $50,99
PRIMARY KEY ( `id` ) is the key to your table, so you only need the id then you automaticly have the entire information of the product that belongs to that id it was of course also possible that `name` was the primary key but id is better

okay just click the first Start button
good the table is ready!

Adding records to the db table

Here you will learn to add products to your database later in the tut this will happen with a form

to add a record, we use the INSERT commando

Code:
INSERT INTO `products` (`name` , `price` )
VALUES ('Mousepad', '10');


let's explain
INSERT INTO is obvious
`products` is the name of the table
(`name` , `price` ) are the rows of the tables
VALUES ('Mousepad', '10'); these are the values of course

don't do this:

Code:
INSERT INTO `products` (`name` , `price` )
VALUES ('10', 'Mousepad');


I hope you see why
the values are not in the correct order!!! the price is Mousepad

okay you've added your first record!

Select records from your table

now I'm going to teach you how you can select your records
to do that, we use the SELECT commando. To select all the records (I know it's only 1) there is just 1 commando

Code:
SELECT * FROM `products`


* doesn't mean all records, but all table rows so id, name and price
if you do this

SELECT name FROM `products` only the name will appear

let's add some more records

Code:
INSERT INTO `products` (`name` , `price` )
VALUES ('Graphix card', '150');
INSERT INTO `products` (`name` , `price` )
VALUES ('Keyboard', '50');
INSERT INTO `products` (`name` , `price` )
VALUES ('Windows XP', '200');
INSERT INTO `products` (`name` , `price` )
VALUES ('PHP Designer 2005', '110');
INSERT INTO `products` (`name` , `price` )
VALUES ('Adobe Photoshop CS 2', '150');


okay this is our shop =)
if u do this now again
SELECT * FROM `products`
you will see the entire table, but most of the times you only want to see just 1 product. well thank you php because that's why we use the WHERE clausule
oh.. PHP

Code:

SELECT * FROM `products` WHERE `name` = 'PHP Designer 2005';

I think it's obvious let's explain it anyway it simply just selects all information where the name of the products = PHP Designer 2005 from the table products

it's just that simple!

Code:
SELECT price FROM `products` WHERE `name` = 'PHP Designer 2005';

this only selects the price of the product where name = PHP Designer 2005 from
the table products

the same for price and id
Code:
SELECT * FROM `products` WHERE `id` = '1';

this selects all records with the id 1 (it's only 1 record of course)

Code:
SELECT * FROM `products` WHERE `price` = '150';

this selects all records where the price = 150
so I think it was photoshop and a new graphix card

So far the select commando and where clausule

Operators

we can use the = sign but we can also use operators for example: we only want to show the products that are more expensive than 100

Code:
SELECT * FROM `products` WHERE `price` > '100';

simple, isn't it?

or you want to select all the records that are cheaper than 50?
Code:
SELECT * FROM `products` WHERE `price` < '50'; u can also use the >= or <= signs Code: SELECT * FROM `products` WHERE `price` <= '50'; this selects the records where the price is = or cheaper than 50 I don't think you ever thought it was that simple ?! More functions with WHERE there's more, you want to select the IDs of the products that are smaller than 3 and you want to select the products that are cheaper than 100? no problem! PHP will take care of it here we will use the AND command Code: SELECT * FROM `products` WHERE `price` < '100' AND `id` < '3'; and there's more... you want to select the products that are cheaper and 50 but also that are more expensive than 200 (I don't know why somebody would do that but it's just an example) here we use the OR command Code: SELECT * FROM `products` WHERE `price` < '50' OR `price` > '200';


Simple eh

Order your records

You want to order your records from cheap to expensive? No problem PHP will take care of it

Code:
SELECT * FROM `products` ORDER BY `price`


you'll get your entire list of products ordered from cheap to expensive but you don't want it this way, but from expensive to cheap? No problem! Just add DESC after price

Code:
SELECT * FROM `products` ORDER BY `price` DESC

DESC means descending

you only want to see a specified ammount of products then you just do this:
SELECT * FROM `products` ORDER BY `price` LIMIT 0,3
0 indicates that he will start counting from 0 and he will take the 3 numbers after 0
so, 1,2,3

SELECT * FROM `products` ORDER BY `price` LIMIT 2,3
he will start counting from 2 and takes the 3 numbers after it
3,4 and 5

UPDATE your records
OMG!!? I've entered the wrong price, I will lose customers!
no problem, that's why we have PHP if you want to update your records, u use the UPDATE command

Code:
UPDATE `products` SET `price` = '250' WHERE `name` = 'Graphix Card';


This will update the price of the graphix card from 150 to 250
(geh thanx, I will lose customers anyway )

if you do this:
Code:
UPDATE `products` SET `price` = '250';

all prices of all your products will change to 250 so beware!

Also here you can use the AND or OR commands in the WHERE clausule!

Combine MySQL and PHP

first of all you'll have to connect to the database open up a new php doc and paste this:

PHP Code:
$server = "localhost";
$user = "username;
$password = "password";
$db = "db";

$connection = mysql_connect($server,$user,$password)
or die ("Could not connect to the database");
mysql_select_db($db,$connection)
or die ("Could not select the db");


server is most of the times localhost, but for freesql.org users it's freesql.org I thought. user is the username u used to register and password as well db is the name of the database u gave while registering ok save this file as connect.php we'll include this file in our other files

open up a new doc
and paste this:

PHP Code:

<?php

include "connect.php";

$query = "SELECT * FROM `products` WHERE `prijs` > '50' ";

$sql = mysql_query($query);

?>




include "connect.php"; just means that all content of that file also are in force in this file.
$query = "SELECT * FROM `products` WHERE `prijs` > '50' ";
this makes the query
$sql = mysql_query($query); this executes the query

now we only have to show all products more expensive than 50

PHP Code:

<?php

include "connect.php"; //make connection

$query = "SELECT * FROM `products` WHERE `prijs` > '50' ";

$sql = mysql_query($query) or die ( mysql_error( ) );



while($record = mysql_fetch_object($sql)){

echo"".$record->name."

";

}

?>



This shows all the products more expensive than 50 or you can do this

PHP Code:

<?php

include "connect.php"; //make connection

$query = "SELECT * FROM `products` WHERE `prijs` > '50' ";

$sql = mysql_query($query) or die ( mysql_error( ) );



while($record = mysql_fetch_object($sql)){

echo"You can buy ". $record->name ." for ". $record->price ." each."

";

}

?>



it always makes a new table
so u better do this:

PHP Code:

// here starts the php
?>?>?>?>?>?>?>?>?>?>?>?>?>?>?>?>?>?>?>?> '50' ";
$sql = mysql_query($query) or die ( mysql_error( ) );

while($record = mysql_fetch_object($sql)){
echo"
".$record->name."";
}
?>
// and close the table
ProductPrice
".$record->price."


well this is not pretty easy to explain but you'll understand after some tries or if u know the while structure

it's not that difficult eh?

More functions with PHP & MySQL
hey I forgot how many products I had no problem PHP takes care of it

PHP Code:

<?php

include "connect.php"; //make connection

$query = "SELECT * FROM `products` WHERE `prijs` > '50' ";

$sql = mysql_query($query) or die ( mysql_error( ) );

$records = mysql_num_rows($sql);

echo ('There are ".$records." in the database');

?>



mysql_num_rows($sql); counts how many records there are in the table

Like I said before, we're going to add records with a form that's exactly what we're going to do now
first we're going to check if the submit button has been clicked
if not: the form will show up
else: we will insert the input into the database

name this doc: insert.php :

PHP Code:

<?php

if ($_POST['submit']) { //if the submit button has been clicked

include"connection.php"; //includes connection.php



$query = "INSERT INTO `products` (`name` , `price` ) //makes the query

VALUES ('".$_POST['name']."', '".$_POST['price']."');"

$sql = mysql_query($query) or die(mysql_error()); //executes the query

echo"You have entered the new product";



}else{

?>

<form method="post" action="insert.php">

Product name: <input type="text" name="name"><br>

Product price: <input type="text name="price"><br><br>

<input type="submit" value="Submit!">

<?

}

?>



I hope this tut helped you out.

3:04 AM

PNG color mismatch on the web: an easy fix

posted under by FR3@K | Edit This
To clarify, this is an easy fix if you have saved your png files from Photoshop and, of course, still have access to the software. I stumbled across this fix in PS and haven't tested in any other applications. Feel free to point out other ones that work in a similar fashion. Note: I was using CS2.

The problem with colors in a png image not matching with other images (such as jpg) or hex color values has been around a long time. It's bugged the hell out of me that I couldn't ever find a very convenient way to get around this issue because png is a superior format to gif. From my understanding, this happens because of gamma correction data that is embedded in the file's meta data. Some browsers will read it, others ignore it. As a result, the actual color of the image can be slightly different than actual color values outside of a color calibrated environment. It's not terribly noticeable most of the time, but if you're working with tiled images it tends to stand out. I've done plenty of digging around (maybe not enough) and the only solutions I ever came across were using 3rd party applications that can read and modify the meta data of a png file, and strip it of the gamma correction information.

Two of the apps I came across that appeared most promising were TweakPNG and PNGCRUSH. TweakPNG is a Windows app, and being that I'm on a Mac this wasn't terribly convenient. While I can certainly boot into Windows or use Parallels to run the app, it's just not worth the trouble. PNGCRUSH is a command line app for DOS or Unix/Linux. Also more effort than it's worth for me.

While working on a site today, I decided to try and work with this problem more to see if anything would come of it. I went ahead and made all the imagery (save for a couple photos in jpg format) png. I thought I could pull it off, but I still had a couple spots where I was using a background color in my stylesheet so it didn't match up with the png images. I remembered the methodology behind the two previously mentioned applications and I started browsing around the menus in PS to see if I could get at any of the embedded data. Turns out, it's completely possible and I'm an idiot for not thinking about it earlier. I suppose it's probably not some hidden menu that no one knew about but I certainly never saw it brought up in any discussions about the png color mismatch dilemma.

After you've saved your file in png format (preferably through the save for web feature), close it and reopen it (so to make sure it's reading the embedded data that was saved with the file). Go to the file menu, then file info. You'll see a window with a list of categories on the left. Go to the Advanced category. Your window should look something like this. Delete the Adobe Photoshop Properties item and the item that just says http://ns.adobe.com/png/1.0/. Click ok, then save your file. The data in the file causing the color shift will now be gone and your images will match up with other image formats and hex color values correctly. It's important to know that if you reopen the file in PS and do any sort of modification (allowing it to be saved again) then it may reapply the embedded data. One additional thing be aware of is that you can put these steps into an action to be reused at any time. It does seem to keep track of how the file info is modified when recording the action.

This fix is kind of stupidly simple, but I was never able to find anyone who used the same method. As a result, I'm writing about it here. If I just completely suck at harnessing the power of Google and it turns out this information is widespread and others have blogged about it, then feel free to ridicule me. Hopefully this helps some folks out anyway.

UPDATE: After some discussion with Jesse, he pointed out that Safari was still forcing a slight color shift (though much less significant than prior to the data stripping). I managed to fix this, at least for myself, by in Photoshop going to the edit menu, then Assign Profile. I assigned a file my working space color profile along with stripping the data out and this seems to make it display correctly in Safari with no color shift. I'm currently unaware if this only repairs it for someone with the same color profile or not but I'll continue testing. However, it does seem that Internet Explorer 6 continues to color shift. All other browsers/platforms I've tested work.

2:54 AM

Show Date Using PHP Strftime

posted under by FR3@K | Edit This
To  show date using php in this format : Friday, 05 October 2007 , using strftime function.
use this PHP snippet :

<?php echo strftime("%A, %d %B %G"); ?>



it is tested and works Great !

2:52 AM

PHP : Get , POST ..

posted under by FR3@K | Edit This

Everything we saw spoke about some variable. I said for example : "$i=1;".

Okay, but it isn't really interactive with the reader.



In order to be interactive we need to permit the reader to send some
information, for example by a form.

The form can send a lot of thing but for instance we just see GET and POST.



SENDING :


If you use the method 'get' you will send information into the URL like :

test.php?name=value&name2=value2 and can can send this sort of URL directly by
the HTML "<a href=".

but you are limited to 255 characters and some of them are restricted.



If you use the method 'post' you will send information without the URL and you
can send a lot of text, code.... but you need to use a form to sending it.



Example of GET :

PHP Code:

<a href="test.php?page=1">Page 1</a>


I don't use any php code to send an information.

the same by form :

PHP Code:

<form method="get" action="test.php">

<input type="text" name="page" value="1">

<input type="submit" value="send">

</form>

Example of POST :

PHP Code:

<form method="post" action="test.php">

<texterea name="mytext"></texterea>

<input type="submit" value="send">

</form>



RECEIVING :

Now An information has been sent to test.php

In order to interact you need to declare or to take the variable POST or GET
like this :

$_POST['mytext']

or

$_GET['page']



They are the same variable as $whatyouwant and you can manipulate them like we
saw before.



Example :

PHP Code:

<?php if ($_GET['page']=='1')

{

echo 'all the text html you want'

}elseif($_GET['page']=='2')

{?>

The other text you want for the page 2

<?php } // note : I close the quote php and reopen one after

?>

So now we can see how to interact with your reader !

2:44 AM

Using PHP to connect to MySQL Database

posted under by FR3@K | Edit This

How to connect a database? I will not expose Phpmyadmin or others software.

You need to have an account to your host with at least 1 database or you need to
have the possibility to connect to another host who have a database.


As ever on PHP, we need to call a function to connect the database, another to
choice the table, another to make a request and another to put/take the result
into a table in the memory.



PHP Code:

<?php
$server='localhost'; /* it's often localhost and always if you have Cpanel,
if you want to connect to another host, put another IP,
you're host says you that*/
$username='myusername'; /* the name of the user of this database,
on Cpanel it's usually username_userofdatabase (shared host)*/
$password='123456789'; /* you're pass for the database
not you're pass from Cpanel*/
$database='mydatabase';  /* the name of you're database,
on Cpanel it's usually username_database (shared host)*/


mysql_connect($server,$username,$password); /* it's a function so ";"
at the end*/
mysql_select_db($database); // it's another function....

Great you are connected, don't forget to close you're connection at the end of
the script (usually the bottom of you're page) :

PHP Code:

<?php mysql_close();?>

You can change the database by setting another one :

PHP Code:

<?php $database2='database2';
mysql_select_db($database2);?>



Now You have to learn another language to communicate with the server SQL. Later
i will put some SQL request to help you.



Make a request :

mysql_query();

Example :

PHP Code:
<?php mysql_query("SELECT name FROM mytable"); // it's a function... ?>

Put it in a table of association and use it :

mysql_fetch_assoc();

Example for one line :

PHP Code:

<?php $request=mysql_query("SELECT name FROM mytable");
$result=mysql_fetch_assoc($request);
echo $result['name'];
// or the same thing :
$result=mysql_fetch_assoc(mysql_query("SELECT name FROM mytable"));
echo $result['name'];

?>

If you have more than one line, you need to put it into a "while" like this :

PHP Code:

<?php $request=mysql_query("SELECT name FROM mytable");
while($result=mysql_fetch_assoc($request)){
echo $result['name'];
}
?>

2:40 AM

Javascript : Random Titles

posted under by FR3@K | Edit This
To have a random site title for you site you would place the following code between your

<head>

tags.

<script TYPE="text/javascript" LANGUAGE="JavaScript">

<!--//

if (parseInt(navigator.appVersion) >= 4) {

var num = 3;

var rantitle = new Array(num+1);

rantitle[1] = "This is random";

rantitle[2] = "Very Random";

rantitle[3] = "Yay it works";

ranNumber = parseInt(num * Math.random() + 1);

document.title = rantitle[ranNumber];

}

//-->

</script>



Now to explain (Explanation has been color coded to match).

This script checks the browser type that the viewer is using and if it's a Netscape 4 or higher, it uses an IF statement to run the code.

Then the code deploys 2 variables. The first is "num" which is the Number of titles and MUST match the number of random titles being used. The second is "rantitle" which is an array that will form the random titles.

Next are the random titles labeled by a number (must never repeat).

The code then draws a random number.

After that the code finalizes by altering the title of the page with the title that matched the random number.

2:38 AM

Basic PHP Tutorial.

posted under by FR3@K | Edit This
here i explain how to set out a PHP script and display text.


Here is a basic echo which displays the string Hello World.

CODE :-



<?php

echo ("Hello World");

?>



Notice the :

<?php




and :

?>





tags at the start and end of the script? These signal to the server when to start executing PHP code and when to stop executing it.

The echo "function" displays whatever is in the area between (" and ") .

At the end of everysingle line of PHP you write, you must put the semi colon; It tells the server to stop reading from this line and go down to the next. Alot of errors in PHP are from people forgetting to put them in.

2:37 AM

PHP if/else .

posted under by FR3@K | Edit This
In this script, we are going to use the built in PHP function rand and use the if statement and the else statement. These are pretty self explanitory, if something is true, then execute some, else (if it isnt true) then execute something else.

CODE :-

<?php

$flip_coin = rand(1,2);

if( $flip_coin == 1 ) {

echo ("You flipped a heads");

} else {

echo ("You flipped a tails");

}

?>



Ok, in this script we are using the built in PHP function called rand() . It chooses a number at random between the 2 numbers you specified. In this case we specified those numbers to be 1 and 2 ( rand(1,2) ). We assigned this to the variable $flip_coin .

Now we are using an if statement. From here the script is English. Its basically saying if the variable $flip_coin is equal to 1, then echo You flipped a heads. If it doesnt equal 1, it must
equal 2, so echo You flipped a tails.

Notice in these if/else/elseif statements the curly braces { }. They are "consequences" (as such) from the if/else statement.

2:34 AM

Using PHP to show user's ip

posted under by FR3@K | Edit This
There are 2 ways that I know of, 1 is garunteed to work and the other is a maybe.


(Garunteed) :-
$REMOTE_ADDR;

(Maybe) :-
$_SERVER['REMOTE_ADDR'];


To show a user's IP simply add this code into any existing php document:QUOTE (show IP)

<?

echo "Your IP is: $REMOTE_ADDR";

?>



NOTE :- The PHP is must be configured right for this to work properly all the time.

2:30 AM

Display time using PHP

posted under by FR3@K | Edit This
You can use this PHP snippet to display the time.

 

<?

$time_offset ="0"; // you many need to change this to offset time zone

$adj = ($time_offset * 120);

$time = date(" h:i:s",time() + $adj);

echo "$time";

?>

2:12 AM

CSS/HTML Tutorial : Effective Footers

posted under by FR3@K | Edit This
Having the right footer is important in a website, it can be a large part of the look of the page. In this tutorial we will be covering how to make a fixed-height footer, which sticks to the bottom of the page except when content pushes it down using purely HTML and CSS. You can see an example of this here. This is not entirely trivial because position: absolute; or fixed; would not move down when the page was filled with content, and merely placing it at the bottom of the markup would not ensure it was at the bottom of the page when there was not much content. The solution to the problem is that we make everything but the footer altogether have a minimum height of 100%, then we use a negative top margin on the footer equal to its total height to bring it up, placing the bottom of the footer at the bottom of the page when the content doesn't have a height larger than 100%, perfect! The HTML required for this is fairly simple, something like this will suffice:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"

"http://www.w3.org/TR/html4/strict.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<title>Footer Example</title>

</head>

<body>

<!-- Container Divs -->

<div id="container"><div id="padding">

<!-- Header -->

<h1>Header</h1>



<!-- Content -->

<h2>Example Content</h2>

<p>

Some content...

</p>

</div></div>



<!-- Footer -->

<p id="footer">

Page Footer

</p>

</body>

</html>


 
Step 2

Now we can start styling the document to get the footer how we want it. First of all, we need to make the container div have a min-height of 100%, this can be achieved in most browsers with the following CSS:

html, body
{
height: 100%;
margin: 0;
padding: 0;
}
div#container
{
min-height: 100%;
}

Both html and body need to be set to 100% height so that the container div can take up the space. This does the job in a lot of browsers, but unfortunately IE doesn't understand min-height, for some reason IE's height is equivalent to min-height and min-height does not exist, so to combat this we need to set height: 100%; in IE without affecting compliant browsers. We can achieve this using !important in the CSS like so:

div#container
{
height: auto !important;
height: 100%;
min-height: 100%;
}

The !important makes compliant browsers use height: auto; instead of height: 100%; while IE uses height: 100%; instead, fixing it nicely. Our layout now looks like this, almost done!
Step 3

Now that our main content area is formatted correctly we can turn our attention to the footer. At the moment it is just below the main content, so we need to apply our negative top margin to pull it up into the correct position. To do this, first we need to calculate its total height, in this case we have made the footer 17px in height, with an additional 9px padding at the top, and another 9px at the bottom. Therefore, the total height of the footer is 17+9+9 = 35px. So we need to move the footer 35 pixels up, which is done with this line:

p#footer
{
margin: -35px 0 0 0;
/* ... other styles ... */
}

This makes the top margin negative 35 and sets left, right and bottom to 0. Now, this is now perfect when there is little content, but when more is introduced to the page we see a problem emerge, the content overflows onto the footer which is hardly something we want. We fix this using the "padding" div that was introduced in the HTML at the beginning, we can't use padding on the container div, because that would make the height of the container div 100%+padding, and would push the footer below the bottom of the page again, so instead we have to pad another container inside the first, in this case the "padding" div. The fix is very simple, and is simply this:

div#padding { padding: 0 0 45px 0; }

Once this is in place, content no longer overflows onto the footer when there's a lot of it, and when there is little the page is unaffected.

Step 4

That's pretty much that on making footers like this, it's a useful tool and widely compatible, this method has been tested on:

IE 5
IE 5.5
IE 6
IE 7
Firefox 2
Opera 9
Konqueror 3.5.7
Safari 2.0.4

2:10 AM

Using references in PHP

posted under by FR3@K | Edit This

2:06 AM

Adobe Photoshop Tutorial: Simple Reflective Surface

posted under by FR3@K | Edit This
In this Photoshop tutorial, we're going to create a simple reflective surface effect for our type. You've probably seen this technique used everywhere, and yet it's extremely easy to do (which could possibly explain why it's used everywhere).
Step 1: Create A New Photoshop Document

As usual, let's create a new document inside Photoshop, either by going up to the File Menu at the top of screen and selecting "New...", or a much quicker way is to use the keyboard shortcut, "Ctrl+N" on a Win system or "Command+N" on a Mac. Either way brings up Photoshop's "New Document" dialog box. Choose the 640x480 size from the Preset drop-down selection box.
Adobe Photoshop Text Effects: Create a new document in Photoshop. Use the 640x480 preset document size

As usual, there's no particular reason why I've chosen 640x480 as my document size other than for the sake of simplicity.
Step 2: Select The Type Tool From The Tools Palette

We can't add a reflective surface to our type without having some type to reflect, so we need to grab the Type tool from Photoshop's Tools palette. It's the icon about halfway down the Tools palette with a capital "T" as its icon. You can either click on it directly in the Tools palette, or use the keyboard shortcut, which is to simply press the letter "T" (as in "T" for Type Tool). Always try to use keyboard shortcuts whenever possible when you're first learning Photoshop, since the sooner they become second nature to you, the more efficient you'll be with the program.
Adobe Photoshop Text Effects: Select the Type tool from Photoshop's Tools palette or press the letter "T" on the keyboard.
Step 3: Select A Color For The Type

As with most things in Photoshop, there's always more than one way to accomplish the exact same thing, and selecting colors is no exception. This time, to keep things simple, let's use the Swatches palette, which contains quite a few "ready to go" colors that we can just click on to select.

The Swatches palette is docked, by default, with the Color palette, another of Photoshop's ways to let us pick colors. To access the Swatches palette, look for the Color palette on your screen, and then look up at the name tab of the Color palette, where it says "Color". Immediately to the right of that tab, you'll see another tab, faded out and hiding in the background, which says "Swatches". That's the Swatches palette hiding back there. We want to bring the Swatches palette forward and send the Color palette back into the shadows, and all we have to do to accomplish this is click on the Swatches name tab. The Swatches palette will instantly move to the forefront and the Color palette will retreat into the background.
Adobe Photoshop Text Effects: Locate the Color palette on your screen, then click on the Swatches name tab to the right of the Color palette's name tab to bring the Swatches palette forward and send the Color palette into the background.

*Note: If you don't see the Color or Swatches palette anywhere on your screen, press the F6 key on your keyboard, which is a shortcut to show and hide the Color palette. Since the Swatches palette is docked with the Color palette, the F6 key also shows and hides the Swatches palette, as well as the Styles palette which is also docked by default with Color and Swatches. Photoshop docks palettes together like this in order to save space on the screen.

To select a color from the Swatches palette, just move your mouse over it and click the color. You'll see your cursor turn into a small eyedropper, as if you're sucking the color up into the eyedropper to use it. I'm going to select the "RGB Red" color in the top left corner of the Swatches palette, but feel free to select any color you prefer.
Adobe Photoshop Text Effects: Move your mouse over any color in the Swatches palette and click on the color to select it. Here, I'm choosing "RGB Red".
Step 4: Select A Font To Use

We have our Type tool, and we have our color. Now, we just need to select a font. You can see a list of all the fonts you currently have installed on your computer up in the Options Bar at the top of the screen, directly below the Menu Bar. The name of your currently selected font is displayed in a selection box on the left side of the Options Bar. To scroll through a list of every available font, simply click the down-pointing arrow to the right of the selection box.

You can choose any font you like for this effect, but keep in mind that this effect works best when using all capital letters. The reason will become clear at the end of the tutorial.

I'm going to select Trajan Pro for my font, but again, feel free to use whichever font you prefer. I'm also going to choose a large size for my font, 72pt. The size for your font is located two selection boxes over to the right of the main font selection box in the Options Bar. It will have a number in it, followed usually by "pt" (for "point"). You can click on the down-pointing arrow to the right of the font size selection box to choose from a list of preset font sizes (which is where I chose 72pt from) or you can type your own font size value into the selection box.
Step 5: Type Your Text

Now that we have our Type tool, our font and our color for the type, we can actually type something. Since this is a tutorial on creating a reflective surface, I'm going to type the word "REFLECTION", and I'm going to use all capital letters to maximize the effect (and to avoid any problems, as I'll explain at the end).
\
Adobe Photoshop Text Effects: Type a word into the document using the Type tool.
Step 5: Duplicate The Type Layer In The Layers Palette

In order to create the reflection effect, we need a copy of our text to use as the reflection. With the text layer selected in the Layers palette (it should be selected but if for some reason it isn't, simply click on it in the Layers palette to select it), press the keyboard shortcut "Ctrl+J" (Win) or "Command+J" (Mac), which will give us a copy of our text layer above the original in the Layers palette.
Adobe Photoshop Text Effects: With the text layer selected, press "Ctrl+J" (Win) or "Command+J" (Mac) to create a copy of the layer directly above the original in the Layers palette.
Step 6: Flip The Original Text Layer Vertically

Now that we have two copies of our text layer (the original plus the copy), we can use one of them as the reflection. Let's use the original text layer as the reflection. Since the reflection is going to be an upside down version of the text, the first thing we need to do is flip the text upside down. Make sure the original text layer is selected in the Layers palette before we go any further (click on it in the Layers palette if it isn't). We don't want to accidentally flip the wrong layer, not that it really matters in this case, but since we've agreed to use the original text layer as our reflection, let's stick to the plan.

With the original text layer selected, go up to the Edit Menu at the top of the screen. Click the word "Edit" to bring up the list of available options under the Edit Menu, and select "Transform". A sub menu will appear with additional options, and the one we want is at the very bottom of the list, "Flip Vertical". Click on it to select it, and you'll see the original text in the document flip upside down.
Adobe Photoshop Text Effects: Select the original text layer in the Layers palette, then select Transform - Flip Vertical from the Edit Menu at the top of the screen.
Step 7: Nudge The Flipped Text Down Below The Regular Text

Next, we need to move the flipped text below the normal "unflipped" text, and it's really easy to do. With the flipped text layer selected in the Layers palette, just use the down arrow on the keyboard to nudge the text downward. You'll have to select the Move tool from the Tools palette first though, since this only works with the Move tool selected. Just press the letter "V" on the keyboard to quickly select it. Now with the Move tool selected, press the down arrow on the keyboard. Each time you press the down arrow key, you'll nudge the text down by 1 pixel. If things are moving a little too slow for you, you can hold the Shift key down while you press the arrow key, which will nudge the text in increments of 10 pixels rather that just 1.

Continue nudging the text down until the top of the flipped text is touching the bottom of the "unflipped text".
Adobe Photoshop Text Effects: Nudge the flipped text down until the top of it is touching the bottom of the normal "unflipped" text.
Step 8: Add A Layer Mask To The Flipped Text

We're just a couple of steps away from being finished. We've nudged our flipped text below the regular text, but it still doesn't look right. We need to make the flipped text fade out as it gets further away from the regular text. How can we do that? By adding a layer mask, that's how.

Rather than sitting through a lengthy discussion about what a Layer Mask is, let's just use one. The more you use them, the faster you'll understand them, and they're by no means rocket science. It just takes a while to wrap your mind around them, that's all. Let's go ahead and add a Layer Mask to our flipped text layer.

At the bottom of the Layers palette is a row of icons. One of them looks like a square shape with a round hole in the center of it. This is the "Add a layer mask" icon. With the flipped text layer selected, click the icon and watch what happens to the flipped text layer in the Layers palette.
Adobe Photoshop Text Effects: Click the "Add a layer mask" icon at the bottom of the Layers palette to add a layer mask to the flipped text layer.

Notice that the flipped text layer now has a white rectangle in it. This is the Layer Mask preview area. Doesn't look like much, does it? Trust me though, it's extremely useful, and the day you completely understand how layer masks work is the day your creativity with Photoshop skyrockets.

By default, layer masks are filled with white, and that's because of the way layer masks work. Any part of a layer where the layer mask is white will be completely visible (100% opaque). Any part of a layer where the layer mask is black will be completely hidden (100% transparent), and we can set any part of a layer to various levels of transparency using gray levels between white and black on the layer mask. The closer the gray is to white on the mask, the more visible that part of the layer will be. The closer the gray is to black, the less visible that part of the layer will be. Photoshop gives us a whopping 256 levels of transparency to play with when using layer masks, meaning white, black, and 254 shades of gray in between.

That sounds like exactly what we need in order to fade our flipped text gradually out of view. We just need a way to create a black-to-white gradient in the layer mask to achieve that effect. As luck would have it, Photoshop happens to come with a Gradient tool for just such a task.
Step 9: Select The Gradient Tool From The Tools Palette

Select the Gradient tool from the Tools palette. It's the one that looks like a rectangle filled with a white-to-black gradient. Or, you can press the letter "G" (for "Gradient") on the keyboard for a quick shortcut.
Adobe Photoshop Text Effects: Select Photoshop's Gradient tool from the Tools palette, or press "G" on the keyboard.

With the Gradient tool selected, Photoshop's context-sensitive Options Bar at the top of the screen will switch to displaying the options specific to the Gradient tool. On the left of the Options Bar, you'll see a gradient preview selection box showing the currently selected gradient. If the gradient showing in the bar is the black-to-white gradient, you're good to go. If it's showing a gradient with different colors, click on the down-pointing arrow to the right of the selection box to view all the gradients which are currently available. The black-to-white gradient is the third one from the left on the top row. Simply click on it to select it, and then click anywhere else on the screen to close the gradient selection box.
Adobe Photoshop Text Effects: If the black-to-white gradient isn't the one currently showing in the Options Bar when you select the Gradient tool, click the down-pointing arrow to the right of the gradient preview box and select it from the list.
Step 10: Select The Layer Mask In The Layers Palette

Before we do anything with our Gradient tool, we need to make sure that the layer mask, not the layer itself, is selected for our flipped text layer in the Layers palette, since we want to create our gradient on the mask, not the layer itself. You can tell if the layer mask is selected because if it is, it will have a white highlight box around the layer mask preview area (the white-filled rectangle). If the layer itself is selected, the highlight box will be around the layer preview area, which in this case is the rectangle with the letter "T" in it, signifying that it's a Type layer.

The easiest way to make sure the layer mask is selected is to simply click on the layer mask preview area on the flipped text layer. If it was selected, it will stay selected, and if it wasn't, it is now.
Adobe Photoshop Text Effects: In the Layers palette, click on the layer mask preview area for the flipped text layer to make sure it's selected before we use the Gradient tool.
Step 11: Drag The Gradient Tool Across The Text To Create The Mask And Complete The Effect

Here we are at the final step. With the layer mask selected, all we need to do now is drag out a gradient to gradually fade out our flipped text.

I'm going to start my gradient roughly halfway between the top and bottom of the flipped text below, and then drag up until I've reached roughly halfway between the top and bottom of the regular "unflipped" text above. Also, I'm going to hold down my Shift key as I'm dragging the gradient upward, which will keep my drag in a perfectly straight vertical line, preventing me from accidentally dragging a little to the left or right and messing up my gradient.
Adobe Photoshop Text Effects: With the Shift key held down to constrain my drag to a perfectly straight vertical line, I begin my gradient halfway between the top and bottom of the flipped text below and drag upward to the halfway point between the top and bottom of the regular text above.

When I release my mouse, Photoshop draws my gradient, successfully fading my flipped text out of view and completing the effect, and this Photoshop tutorial.

1:57 AM

Reference

posted under by FR3@K | Edit This
The reference operator & was added to PHP in version 4. References are useful when you want to refer to a variable by using a name other than its original one.

$x = 3 ;
$y = &$x ;

The second statement creates a reference for $x named as $y. After now we can access the variable by using its original one or the reference. As we assign a value to one of them, the other has the same value. In fact a reference has not a memory for the value. It only references the original variable.

$x = 5 ;

$x and $y are both 5 after this statement. The reference operator may remind you pointers in the C language. The function is similar but you can't assign the address of a reference manually.

1:57 AM

Assignment Operators

posted under by FR3@K | Edit This
The main assignment operator is = which is used to assing the right side value to the left. It doesn't mean 'equal to' as in maths. It means 'set to' . This operator returns the result of the assignment.

$x=18;

This statement has the value 18 . A better example:

$x= ($y=3) + ($z=$y-1) ;

This statement assigns 3 to $y, substracts 1 from $y and assigns it to $z and then adds them to assign the result to $x . There are some combined assignment operators too:

operator example equivalent

+= $x+=$y $x=$x+$y
-= $x-=$y $x=$x-$y
*= $x*=$y $x=$x*$y
/= $x/=$y $x=$x/$y
%= $x%=$y $x=$x%$y
.= $x.=$y $x=$x.$y

1:56 AM

Arithmetic Operators

posted under by FR3@K | Edit This
Arithmetic Operators in Php are just like the ones you use in mathematics.

+ addition $x + $y
- subtraction $x - $y
* multiplication $x * $y
/ division $x / $y
% modulus $x % $y

These operators are binary (they take two operands) but the subtraction (-) operator is also unary when used with negative numbers. The modulus operator returns the remainder of dividing its operands.

$mod_result=18 % 4;

This statement has the value 2 as a result. If you try to use arithmetic operators with strings php will try to convert the strings to numbers starting from the first character. If there are no digits at the beginning of the string the value of it will be zero.

1:56 AM

Concatenate Strings

posted under by FR3@K | Edit This
when you need printing more than one strings where there may be variables or other things between them, it would be annoying to write a new statement to echo all the parts. php has a nice way of doing this for you, string concatenating
let me show you an example:

echo "you have " . $msg_num . "messages!" ;

the . operator is the string concatenation operator and is very useful for situations like this. ( i left spaces after and before '.' operators to make them more visible. this is not needed in fact. )
you could also write the statement above like that without string concatenating :

echo "you have $msg_num messages!" ;

this will give an output like:

you have 3 messages!

depending on the variable $msg_num .
be careful that you can do this only inside double quotes. if you use a statement like that:

echo 'you have $msg_num messages! ' ;

you 'll get html output exactly as in the quotes:

you have $msg_num messages!

there should be a value instead of $msg_num here so we should use double quotes for this statement. single quotes give output without changing.

1:55 AM

Constant

posted under by FR3@K | Edit This
Constants are like variables but their values can't be changed after they are set. Constants are defined like that:


define( 'MY_CONSTANT' , 298 );

this statement defines a constant named as MY_CONSTANT . you don't need to write the constant names with all capital letters but i can say that this is common (or traditional) for defining constants in some other languages too.
while using a constant in the rest of your code you just write its name anywhere that you want its value to be.

echo "my constant is: ";
echo MY_CONSTANT;

you see that we put no $ sign before the constant name. that's because a constant is not a variable. constants will be very useful when you have a constant value in your code that is used many times in the code and you frequently change it. by using a constant you don't need to change every statement that has the value you want to change. you only change the definition of the constant. you may also want to use constants when you want to keep some special values that you don't want to memorize or write everytime you need it (pi, speed of light, gravity constant etc.) .

1:55 AM

Variable Variable

posted under by FR3@K | Edit This
In php you can use "variable variables" to reference the name of a variable by using another variable. this may remind you pointers if you are familiar with C/C++ languages but actually its not the same. variable variables allow you to change the name of a variable. C and C++ don't support this.

$var_name='my_variable';
$$var_name="value"; //equal to: $my_variable="value";

in this example $$var_name is equal to $my_variable . the second statement assigns the string "value" to $my_variable . (simply put 'my_variable' instead of $var_name). this way you can change the variable name dynamically and use the same expression

$$var_name="value";

for accessing different variables. this feature is sometimes very useful. (for ex: when you keep variable names in an array and use them in a loop.)

1:51 AM

Variables

posted under by FR3@K | Edit This
variables are data symbols carrying a value. in php variables are defined by using a $ sign before an identifier. identifiers are the names of variables. identifiers can't begin with a digit and may include letters, numbers, underscores and the $ sign. using the $ sign has a special meaning for variables (i won't mention about it now.) the name of a variable is case sensitive and you can't use function names as variable names. unlike the c language, in php you don't have to declare a variable before using it. the variable will be created when you first use it.

$myvariable=0;

this is a simple assignment to a variable named as 'myvariable'. php supports these data types:

integer
double
string
boolean
array
object

double is used for real numbers, string is a set of characters, boolean is a logical variable for values true and false, arrays are used for multiple number of variables of the same type and objects are used to store class instances. since php 4 the types NULL, boolean and resource are valid. variables that don't have any value, unset or given the value NULL are of NULL type. some functions return the type 'resource' that you use for handling some special data like database query outputs.
notice that we haven't used any type indicator before the name of the variable in the previous example. in php the type of a variable is the same as the value it has. for example:

$myvar=3;
$myvar=3.14;
$myvar="hello world";

the first statement (creates if not created yet and) makes $myvar an integer, the second statement makes it a double and the last makes it a string by assigning the values in the statements. you can also make type casting when you want the variable to be in an exact type.

$myint=1 ;
$mydouble=(double) $myint ;

the first statement gives the value to $myint as an integer and the second makes an assignment from $myint to $mydouble by casting the type to double although the value is the same actually. $myint is still an integer after type casting.

top