Peep in my mind

Tags: , ,

Numbers

Posted on 11 June 2009 by admin

php101
Doing math in php

$variable = value * value
$variable = value + value
$variable = value – value
$variable = value / value

Formatting Numbers

Rounding numbers – rounds values to specified decimal places. It can be number or variables. There is an option that allow users to round too the number of decimal places.

Example:
round (6.20); = 6
round (6.369, 2); = 6.37
$number = 694.2783;
round ($number); = 694

Number format – works like round but adds commas in the to numbers.
number_format (6.2243, 2); = 6.22
number_format (69, 2); = 69.00
number_format (123456789); = 123,456,789

Precedence - the order in which calculations are made.

8 – 4 / 2 = 6 and not 2 because division comes first.

To avoid this use ()
(8 – 4) /2 ) = 2
8 – (4 / 2 ) = 6

Incrementing and decrementing a number add or subtracts 1 value
$var++; or $var–; this will give the value +1 or -1 effect.

Creating random numbers

rand()

$n = rand();- this generate random number
$n = rand(0,100); – this generate random number 0 to 100

Other types are getrandmax() – get height random number
mt_rand() – it suppose to work better then rand and great for cryptography.

These notes are from PHP for the World Wide Web, Third Edition (Visual QuickStart Guide) written by Larry Ullman. In order to make sense of my notes you should pruchase the PHP book its very well written and easy to follow.

Comments (0)

Tags: , , ,

Wordpress won’t Upload my image fix

Posted on 10 June 2009 by admin

wordpress-logo

So I recently moved one of my wordpress site from one spot to another.  Well that no biggy but the problem was I couldn’t upload images.  I was baffled for half an hour why my image wouldn’t upload to the upload folder.  Or why my image wasn’t being displayed.  So after a little bit of playing I found out the problem and here how I fixed it.

Go to Wordpress backend and go to Settings\Miscellaneous.  The go to the Store uploads in this folder and edit the directory to the proper lockation.

A simple fix but lots of hair pulling!

Comments (0)

Tags: , , ,

Creating Forms with HTML and PHP

Posted on 10 June 2009 by admin

php101

Forms

Code to generate forms goes between <form> data </form> tags.  In the opening form tag also contains an action attribute.  This indicates which page the form data should submit.
<form action=”submit.php”>

There are two methods of transmitting data from the form to the handling script. They are GET and POST.  The GET method sends all the gathered information along as part of the url. The Post method sends the data invisibly.

Example of the GET method.

http://www.blah.com/page.php?var=value&blah…

Example of the POST method.

http://www.blah.com/page.php

Notes to keep in mind about GET method.

  • GET method is limited amount of data that can be transferred.
  • Data can be view publicly which may cause security risk.
  • A page created by GET method can be bookmarked.
  • GET pages can be reloaded POST pages will have a confirmation box

To used the form data submitted users need to use predefined variables.  They are $_GET and $_POST they are used based on which type of method is picked when generating the form.  If the method was post then use $_POST if the method was GET then use $_GET.  Also the variable must be typed with all caps cause it is case sensitive.

Sample code form.html

<body>
<form action=”display_form.php” method=”post”>
<p>Comments: <textarea name=”comments” rows=”3″ cols=”30″></textarea></p>
<input type=”submit” name=”submit” value=”Send Comment” />
</form>
</body>

Sample code display_form.php

<body>
<?php
$comments = $_POST['comments'];
print “<p>Thank you for the comment <br />$comments</p>”;
?>
</body>

These notes are from PHP for the World Wide Web, Third Edition (Visual QuickStart Guide) written by Larry Ullman. In order to make sense of my notes you should pruchase the PHP book its very well written and easy to follow.

Comments (0)

Tags: , ,

PHP Variable Notes

Posted on 09 June 2009 by admin

php101

Variable – is like a magic box that stores information once the information is stored in the box it can be changed, or taken out to be displayed.

All variable names must be have a dollar sign “$” at the start of the variable.

After the dollar sign “$” the variable name must start with  a letter “A-Z” or “a-z” or a underscore “_” it cannot start with a number

After the “$” the rest of the name can be any combination of letters, numbers, and underscores.

Spaces can’t be used in variable names please use underscores “_” to represent spaces

Variable names are case sensitive so “$_cat” and “$_Cat” is different. (Try not to use variable with same names to reduce confusion).

Tips on creating variables

  • Always use lowercase on variable names
  • Always make your variable name descriptive
  • Always comment the purpose of the variables
  • Always try to defined all variables before use even though PHP doesn’t require it.

Variable Types

Numbers

There are two types of numbers in PHP Integers and floating-point.  Integers are whole numbers that can be both positive or negatives but cannot have fractions of decimals.  Floating-point numbers are use to if numbers have decimal places.  (The only way to use fraction in PHP is to covert to decimals).

Integer = 1 or -1

Floating-point = 1.02 or -1.02

Strings

A string is any number of characters enclosed in single or double quotation marks ’string’ or “string”. Strings can be numbers letters symbols and spaces.  Stings can also contain variables. Strings can only contain 1 value.

To use quotation marks in a string use the backslash \.
Example: “Yo, “ho ho!”" would have to be written “Yo, \”hoho!\”" in order for it to display properly.

Different quotation marks can be used to fix the problem.
Example: “Yo, ‘ho ho!’” or ‘Yo, “ho ho!”‘.

Arrays

Arrays can contain a list of values so users can put multiple strings and numbers in to one array.

Array uses keys to create and retrieve that values stored. Php has two different types of arrays. An “Indexed array” uses numbers for its keys. An “Associative array” uses strings for its keys.  An array containing other arrays is called a “multidimensional array”.

Assigning Values to Variables

To assign a value to a variable the user must use the = sign.  The equal sign is called the “assignment operator” because it assigns a value to the variable.

Variable assignment operator value
$string = “Yo Ho!”;

Differences between Quotation marks ‘/”

Single quotation marks ” are treated literally
Double Quotation marks take the value of the variable.

These notes are from PHP for the World Wide Web, Third Edition (Visual QuickStart Guide) written by Larry Ullman. In order to make sense of my notes you should pruchase that excellent PHP book its very well written and easy to follow.

Comments (0)

Tags: , , ,

How to change wordpress URL setting back to original URL.

Posted on 28 May 2009 by admin

wordpress-logo

I was playing with my blog I changed the wordpress address (URL) settings under general settings.  This cause some problems obviously it pretty much broke my wordpress and most of my functions didn’t work. So after taking sometime trying to figure out how to revert my settings I finally figured it out!

First you have to go in to the SQL database (I use phpMyAdmin so I use that to explain how I fixed it from there). In phpMyAdmin go in to your database and got the “wp_options” section.

There you should see “siteurl” under the “option_name” column and right next to it is the “option_value” there you will see your newly entered url.

To change it just click on the edit button and change that current url to what it was originally hit save and everything so be just fine!
Well at least it worked for me ;D

Comments (1)

Tags: , , , , ,

Tutorial On Creating Your Favicon For Yor Website

Posted on 21 May 2009 by admin

Creating A Favicon

So I bet you all wondered like I did how do they create those neat icons on their web site and have it displayed in the bookmarks? Well here a few short steps on how to make one.

First you need to create a image that is 16×16 pixels because this is the size for the icons for the bookmark and browsers. Once you have Create that icon favicon (that one is mine) save it out as a .gif or a png with transparency if you need it.

Next we will go to our favorite web page http://tools.dynamicdrive.com/favicon/ where they are super nice and have given us a tool to create our favicon! Yes that right we don’t have to install any software just upload and download.

Once you have created your FavIcon for your website upload it somewhere on your website.  Please make sure you know where you saved it cause you will need to link back to that file.  I put mine in the same wordpress theme folder that I am currently using.

The next step is to open up your page and go to the HEAD section and add the link.

<link rel=”shortcut icon” href=”/favicon.ico”>

If your using wordpress and uploaded the icon to the theme folder you are using please use the code below. Just copy and paste the code in the HEAD section of that theme.

<link rel=”shortcut icon” href=”<?php bloginfo(’template_directory’); ?>/favicon.ico”>

Once you’ve added the code save your page and your done.

Comments (1)

Tags: , , , , , ,

PHP 101

Posted on 17 April 2009 by admin

php101

I started to pick up PHP and started reading this book PHP for the World Wide Web, Third Edition (Visual QuickStart Guide) written by Larry Ullman. Like any good student I like to make notes when I read then type it out mainly just so I can review what I just learned. (yeah it sound geeky but oh well only way i can learn) and since coding has never been my best subject I really do need to type it out over and over again. Anyways I figured I might as well keep my notes on my blog and share with you all. So if your reading my blog and trying to use my notes you should pick up the book too and follow along!

Definition of PHP

originally stood for Personal Home Page but it later changed and it now currently stands for Hypertext Preprocessor

  • php is an HTML embedded scripting language
  • php server side language
  • php allows users to create dyanmic pages
  • can run only on Php enabled web servers.

Basic PHP Syntax

  • PHP scripts should be save as a .php file
  • place php code within <? php code ?> tags
  • open “<?php”
  • closed “?>
  • php statements must end with “;” or error will occur.

Function

  • Functions in php are followed by parentheses () in which arguments are passed to the function.
  • php is case-insensitive when calling functions (variables are case sensitive in php).

Function: phpinfo()

  • this function list the spec of the php install on the sever
  • this is also a great way to test if php was installed properly on the server

Example :

<?php

// Show all information, defaults to INFO_ALL

phpinfo();

// Show just the module information.

// phpinfo(8) yields identical results.

phpinfo(INFO_MODULES);

?>

Function: print()

  • use to display text or Output a string
  • strings must be surrounded with ” ” numbers don’t.

Example:

<?php print (”Hello World”) ?>

Function: echo()

  • use to Output one or more strings

Example:

<?php echo (”Hello World”) ?>

Function: printf()

  • use to Output one or more strings

Example:

<?php printf (”Hello World”) ?>

To find more functions go to php.net./manual

Comments (2)

Tags: , , , ,

Multi-Column Layout Using CSS 3

Posted on 31 January 2009 by admin

I originally wrote this for work.  I figured I’d post it on my blog also, guess I’m a re-blogger after all.

Multi-column layout

The CSS3 function for Multi-Column Layout allows the user to creating a design similar to a Newspaper layout. With designs of blogs and websites heading towards a magazine layout type of style I figured this is truly a helpful style to use.

Multi-column Layout Properties

column-count: 3;  this sets the number of columns for which the content will flow.
column-width: 1em; this property sets the width of each column.
column-rule: 1px solid black; this sets a border between the columns.

column-css3

Code sample:
Continue Reading

Comments (0)

Tags: , , , , ,

CSS Transparency and Rounded Corners Techniques

Posted on 13 December 2008 by admin

css_transparency_rounded_corners

After going through a few projects and picking up some css skills along the way here are some neat css tricks I’ve learned and found very helpful.  So helpful I figured I write somewhere so I can always find what I need instead of using google all the time. The first bit of code is setting transparency for objects like images and divs. it can be a nice effect for  setting transparent backgrounds behind some funky bg image.

Codes for setting transparency:

For current firefox, safari browser
opacity:0.7;

For firefox browser
-moz-opacity:1.0;

For ie browser
filter: alpha(opacity=100);

Now here is something I’m completely stoked about and that is rounded corners.  I’m not sure about you but  I’ve always hated cutting out rounded corner images out just to make rounded corners(my blood is boiling just thinking of it).  Luckily the code below help eliminate most of these issues below are the code to create  rounded corners for safari and mozilla.  As for ie I don’t believe they support it yet but if you know they do please let me know ;D

Code for making rounded corners:
Continue Reading

Comments (0)

Tags: , , , , , , , , , , ,

Installing WPMU | WP Locally On Windows XP

Posted on 05 June 2008 by admin

install_wpmu_wp_locally

1. Download XAMPP you can download XAMMP or light version doesn’t matter.

2. Install in your C drive You can skip the next few steps if you want if you’re not installing WPMU

a. C:\WINDOWS\system32\drivers\etc\host change localhost to localhost.enter_a_name

b. Go To apache\conf\httpd.conf

c. Change

#LoadModule rewrite_module modules/mod_rewrite.so
to
LoadModule rewrite_module modules/mod_rewrite.so

Continue with WP/WPMU install.

3. Download wordpress or wordpress-mu extract the files into your c:\xampp\htdocs dir.

4. Now run C:\xampp\xampp-control.exe and click on start button for apache and mysql.

5. Open your web browers and enter in the url: http://localhost/ or http://localhost.enter_a_name if did steps a, b, and c.

6. Select a language and click on phpMyAdmin.

7. In the Create new database fields enter wordpress and select utf8_unicode_ci and hit the create button.

8. Change url to http://localhost /your_word_press_folder/ or http://localhost.enter_a_name/your_word_press_folder/ in the Database section enter the following

Database Name:wordpress

User Name: root

Password: erase whatever is there and leave blank

Database Host: Leave it as “local host

9. Fill in your Site Details and press Submit and your done!

Comments (6)

Advertise Here
Advertise Here

RELATED SITES