Photoshop palette
Creating a custom Swatch
Photoshop training

Customizing Max Interface
Learn how to customize 3d Studio Max interface and viewports
3d Studio Max

Learn Flash
Start to learn Flash. See some important features to start learning this imaging software.
Flash Training

Dreamweaver Enable/Disabled script
How work with Browser with Javascript disabled
Learn Dreamweaver

Understand Sessions
Learn how php sessions work
in Php programming

Redefine tags and create classes with Css
manage different types of html tags, classes and styles
Cascading Style

navigation

Share Tips

Photoshop Light filter effect

When we're working with light filter effect it's possible to click on every light holding Alt button down and drag that layer to multiply the light.

 

Affiliates

tutorio.com free webmaster tutorialsAK Productions Studios

Bookmark

del.iciou.us icon Technorati Ma.gnolia send this page icon

Like this site? Digg it ;)

Get rid of Warning: division by zero on line..

Php is a great language because it allows you to create great web application but it may be useful even for calculations. Php is often used creating graphics on the fly starting from simple data.
If you’re projecting a script tide up with math you may encounter a typical error that come out when you try to divide a number by zero.

The result of such operation would be a “number” that leads to infinite so, for this reason, php returns a warning. If this warning if print on screen or not it depends by your php.ini configuration that may be set on E_ALL or not.

The problems starts if you cannot edit the php.ini file like on remote servers that are not completely under your control.

Let’s avoid the problem.

To test the Warning we need two values. Simply an $a set to 5 (or any other value) and $b set to 0. $c stores the result of the division :)

<?php
$a = 5;
$b = 0;
$c = ($a/$b);
echo $c;
?>

And that’s our warning

Warning: Division by zero in […] on line …

Believe it or not this is a very common mistake across the web even in professional application. Make a search with the keywords above and see it yourself.

To prevent the warning output we’ll use @
@ tells to php.. do not print/output nothing in case of errors, warning and so on..

edit this way: @($a/$b)

<?php
$a = 5;
$b = 0;
$c = @($a/$b);
echo $c;
?>

No output at all. Well this result may be useful or not. It depends by the script itself. Usually an output is always needed so not output at all may not be what we want to obtain.

With an if else statement we’ll improve our script.

<?php
$a = 5;
$b = 0;
$c = @($a/$b);
echo $c;

if($c == 0)
{
echo "ops.. zero!";
} else {

// rest of the script here
// assuming that b it’s different from zero.. ;)

}
?>

Consider that you may use this simply code for rating systems when there are no vote jet.
An average it’s a sum of votes divided by the number of the votes. What if vote = 0 (i.e. $b = 0)? A great warning.. so use this easy solution and go ahead..

Hope this help.

copyright © 2006-2007 http://www.cagedflame.com 7 on line The Host Choice