Sunday 16 June 2013

How to Create Crystal Reports in Visual Studio.Net from Scratch! Part 1

In this video you will learn all about creating Crystal Reports using a popular software called Visual Studio.Net. Simple straight forward video: Its much easier to learn by watching. So sit back and enjoy!

Wednesday 9 June 2010

A Good use of RowCount in SQL Server 2005 and 2008

If you are in a situation where you want to limit the number of rows return for a given query just use Rowcount. Easy!

For example you have a scenario where you want only to show the 8 most recent orders out of 25 orders. So you can just set the rowcount to 8 and this is what will be returned.

NOTE: Then don't forget to set the RowCount back to 0 to reset it.

SET ROWCOUNT 3
-- Get list of orders
SELECT OrderID, DateCreated, DateShipped,
Verified, Completed, [Cancelled], CustomerName
FROM Orders
ORDER BY DateCreated


In this SQL query above, only the 3 records will be returned. And then to reset the RowCount just type:

Set ROWCOUNT 0

This will reset the ROWCOUNT for the query.

Easy isn't? Just try it!

Cheers!

Saturday 10 April 2010

How to generate random passwords for PHP users.

Hey guys.

I have a script that I'd like to share and it is about generating random password. You can very well use this script for your new user registration. And then mail it to them.

This is useful when people create accounts and have easy to remember passwords but passwords shouldn't be easy to guess. Therefore, this script is going to output something that will be hard for user to guess.

Here it is:

function GeneratePassword($min = 5, $max = 8) {
$ValidChars = "abcdefghijklmnopqrstuvwxyz123456789";
$max_char = strlen($ValidChars) - 1;
$length = mt_rand($min, $max);
$password = "";
for ($i = 0; $i < $length; $i++) {
$password .= $ValidChars[mt_rand(0, $max_char)];
}
return $password;
}
echo "New Password = " . GeneratePassword()
. "\n";
echo "New Password = " . GeneratePassword(4, 10) . "\n";




Now all you have to do is call this function and you are there!

Enjoy!

How to Set an upload limit in PHP for a file.

Alright guys here it is. Very straight-forward.

I will this with you. It may be easy to locate but most of the people aren't aware of it. So here it goes.

All you need to do is locate and open you php.ini file and just look for this word:

upload_max_filesize

It will look something like this:




And in this figure the upload limit is set to 2 Megabyte. You can set any limit you want. You can increase it or decrease the limit.

Its your choice depending upon the server capability and network traffic you have over the server.

Enjoy and leave your comments down below.

Thanks!

How to Enable/Disable Image upload in PHP

Hey Guys as promised I have yet another tip to share with you.

In this post I am going to talk about how we can disable the file upload in PHP. It is fairly we simple.

All you have to do is just open up you php.ini file and locate the word:

file_uploads

As shown in the image below:



Now you can turn it On or Off.

If you turn it off the server will not accept any file uploads. Its that simple!

Enjoy!

Sunday 4 April 2010

New Cool stuff in Javascript!

Hey guys, today I learned some new stuff in Javascript. I am gonna share 'em with you later on.

Just keep tuned in as they are pretty cool stuff.

Cheers!

How to check if a file exists in your Web Server!

One thing I came across which was quite interesting was to check if a file exists before we do any operation on the file itself.

We do that by using a php function and we do that by:

if (file_exists('file.txt')) {
print 'OK, file.txt exists.';
}

Alright this is pretty much self-explanatory, here what we are doing is checking if the file exists or not. And if does, we simply print the message. You can simply use this function in your programs before working with the file otherwise this might throw an error if the file doesn't exists.

Very simple!

Making a String Uppercase, Lowercase, or Capitalized!!

Ok in this post I am going to show you how to Uppercase, Lowercase, or Capitalize a string or a word, I mean, making a work UPPERCASE or lowercase or Capital Word. Hmm now I guess I got things much clearer for you.

Now we'll first start with uppercase, the way we do that is:

$string = "heY hOw arE yoU doinG?";
echo strtoupper($string);
// Displays "HEY HOW ARE YOU DOING?"

What we did here is we used a PHP function called string to upper or strtoupper()

Likewise, we have the string to lower i.e strtolower()
echo strtolower($string);
// Displays "hey how are you doing?"

And yes, of course, we have the last one... called Uppercase. What this will do is uppercase everything:

$string="hoW ARE yOU doInG?";
echo ucwords(strtolower($string));
// Displays "Hey How Are You Doing?"

Important: Here, we have used a function ucwords() but before we did that we used the strtolower() function to lower case all the characters in the string... then.... we Capitalized the words in the string. Make sense?

I hope it did.

Enjoy and leave comments below!

How to check if a variable is null in PHP!

As we were talking about various functions in PHP, one of the functions to check if the value is null is: is_null($MyVal) and here if the values is null it will return true and false if the value is not null.

You can always go for something like: !is_null($MyVal) that way, if the value is not null then do something.

Very simple and straight forward!

Ok again, leave your comment down below.

Cheers!

How to Check if the number is numeric in PHP.

When you are working with functions in PHP and sending numeric data you always might want to check if the number passed is an integer.

We do that by using an built-in function and that is is_numeric($MyNum) here $MyNum is a variable that is passed to this function and we can always have if-else condition i.e it will return true if numeric or false if not numeric or vice-versa.

If you take a look at the php documentation, there are plenty of functions that you can look into.

I just thought of sharing this one with you. coz this one is very simple and it can save a lot of time trying to figure out what went wrong if the user has sent data in an incorrect format.

Cheers!

And don't forget to leave comments down below