Categories
Uncategorized

Migrate from MySQL to MySQLi & vice versa

There have been many questions on how to migrate from MySQL to MySQLi. Well adding the letter i to mysql wouldn’t solve the problem while you are migrating. There is a change in the method of query. First of all you need to have a basic knowledge of MySQL to follow this post.

MySQL – Create a Table

$table = "CREATE TABLE IF NOT EXISTS Users (
		 		 id int(11) NOT NULL auto_increment,
				 username varchar(255) NOT NULL
                                            )";

mysql_query($table);

MySQLi – Create a Table

$link = mysqli_connect("localhost","username","password", "databasename");
$table = "CREATE TABLE IF NOT EXISTS Users (
		 		 id int(11) NOT NULL auto_increment,
				 username varchar(255) NOT NULL
                                            )";
$query = mysqli_query($link, $table);

The same $link has to be passed whenever you are using the MySQLi type mysqli_query()command. For example when you are using commands like INSERT, SELECT,  DELETE,etc you have to pass the $link parameter shown above. The mysqli_query() defaultly expects two parameters to be passed. One is the $link paramter which connects to the database and the other is the query operation.

In case you do not provide the $link parameter in your query, then you will get an error like this while processing your page:
mysqli_query() expects at least 2 parameters

Also read: MySQL vs MySQLi which is better and What’s the difference – Explained!

Now moving onto other MySQL commands, like mysql_real_escape_string() the change in the MySQLi format can be seen below.

$demo = mysql_real_escape_string($email1);
$demo = mysqli_real_escape_string($link, $email1);

If the $link parameter isn’t passed through the mysqli_real_escape_string() then you will see the following error when you go to your page:
mysqli_real_escape_string() expects exactly 2 parameters

the mysql_error() command in MySQL and it’s equivalent in MySQLi can be seen below:

mysql_error();

 

mysqli_error($link);

If you do not pass the $link parameter then you are likely to see the following error:
mysqli_error() expects exactly 1 parameter, 0 given

the mysql_num_rows() command in MySQL and it’s equivalent in MySQLi can be seen below:

$sql = mysql_query("SELECT username FROM Users WHERE username='admin'"); 
$check = mysql_num_rows($sql);
$sql = mysqli_query($link, "SELECT username FROM Users WHERE username='admin'"); 
$check = mysqli_num_rows($sql);

the mysqli_fetch_array() command in MySQL and it’s equivalent in MySQLi can be seen below:

$sql = mysql_query("SELECT id, username, firstname, lastname FROM myMembers WHERE id='123' LIMIT 1");
$row = mysql_fetch_array($sql);
$sql = mysqli_query($link, "SELECT id, username, firstname, lastname FROM myMembers WHERE id='123' LIMIT 1");
$row = mysqli_fetch_array($sql);

So these are the major differences between MySQL and MySQLi commands. Hope you will find it easy to migrate from MySQL to MySQLi using these. The MySQLi commands are all in precedural form instead of Object-Oriented Style. If you have any queries regarding this process then please feel free to reach me through the comment section.

Categories
Uncategorized

MySQL vs MySQLi which is better and What’s the difference – Explained!

There has been a huge discussion over the internet about using MySQL or MySQLi in their PHP code. Before getting to that part, one must have a basic knowledge of it, so lets get started on it. To start off with, there are three main API options when considering connecting to a MySQL database server. They are,

  • PHP’s MySQL Extension
  • PHP’s mysqli Extension
  • PHP Data Objects (PDO)

Of course each of them have their own set of advantages and disadvantages.

What is PHP’s MySQL Extension?

This is the original extension designed to allow you to develop PHP applications that interact with a MySQL database. The mysql extension provides a procedural interface and is intended for use only with MySQL versions older than 4.1.3. This extension can be used with versions of MySQL 4.1.3 or newer, but not all of the latest MySQL server features will be available.

If you are using MySQL versions 4.1.3 or later it is strongly recommended that you use the mysqli extension instead.

In the PHP installation on the remote server or local server, the mysql extension source code is located in the PHP extension directory ext/mysql.

 

What is PHP’s mysqli Extension?

The mysqli extension, or as it is sometimes known, the MySQL improved extension, was developed to take advantage of new features found in MySQL systems versions 4.1.3 and newer. The mysqli extension is included with PHP versions 5 and later.

The mysqli extension has a number of benefits, the key enhancements over the mysql extension being:

  • Object-oriented interface
  • Support for Prepared Statements
  • Support for Multiple Statements
  • Support for Transactions
  • Enhanced debugging capabilities
  • Embedded server support

If you are using MySQL versions 4.1.3 or later it is strongly recommended that you use this extension.

Along with the object-oriented interface the extension also provides a procedural interface.

The mysqli extension is built using the PHP extension framework, its source code is located in the directory ext/mysqli in the PHP installation in the remote server or local server

I personally use MySQLi extension in my projects as i feel it has future use and it can be used in both Object-Oriented Style and Procedural Style. The official website for PHP itself states reasons for opting the MySQLi extension.

Read about: Migrate from MySQL to MySQLi & vice versa

Why MySQLi?

The mysqli extension allows you to access the functionality provided by MySQL 4.1 and above.

The persistent connection of the mysqli extension however provides built-in cleanup handling code. The cleanup carried out by mysqli includes:

  • Rollback active transactions
  • Close and drop temporary tables
  • Unlock tables
  • Reset session variables
  • Close prepared statements (always happens with PHP)
  • Close handler
  • Release locks acquired with GET_LOCK()

This ensures that persistent connections are in a clean state on return from the connection pool, before the client process uses them.

The mysqli extension does this cleanup by automatically calling the C-API function mysql_change_user().

The automatic cleanup feature has advantages and disadvantages though. The advantage is that the programmer no longer needs to worry about adding cleanup code, as it is called automatically. However, the disadvantage is that the code could potentially be a little slower, as the code to perform the cleanup needs to run each time a connection is returned from the connection pool.

It is possible to switch off the automatic cleanup code, by compiling PHP with MYSQLI_NO_CHANGE_USER_ON_PCONNECT defined.

For more information regarding MySQL, you can visit their official website here.
If you have any queries regarding this topic then please feel free to reach me through the comment section below.4

Categories
Uncategorized

Learn “How to use Google Effectively” in under 5 minutes!

Google is the most powerful tool out there for everyone today, but most of the people still don’t know how to use it to the fullest. Few interesting ways to use Google are listed below.

Search within a particular Site

To search for results from a particular site all you have to do is follow the following Syntax shown here.
site:collegestash.com windows 8

Phone Numbers

Search for phone numbers in Google using the following Syntax that has the word phonebook followed by a ” : ” and the unknown phone number or to be more specific you can use the other formet also listed below.
phonebook:555-555-5555
or
555-555-5555

Files

To search for specific file types all you have to do is, specifying the specific filetype as shown below.
“Famous Five” filetype:pdf

Word Definitions

Google can also be used to get word definitions by using the following Syntax.
define:cricket

Weather

You can know the weather conditions of your current location by just a few keystrokes as shown below.
weather:hyderabad

Calculator

Google can be used effectively as a calculator.  Few examples are given below.
sin(72)-cos(45)
and
175^34

This HD video will show you the demonstration:

https://www.youtube.com/watch?v=Wngp8I4HrkU

If you have any queries regarding this, then please feel free to reach me through the comment section below.

Categories
Uncategorized

TASM 64-Bit (Full screen)

TASM (Turbo Assembler by Borland) Version 5.0 doesn’t work directly on a 64-bit Windows OS. You will have to install DOS Box on your system and then mount Drive E to work like it does on a 32-bit OS running system. But you still won’t be able to run it in full-screen mode. The file provided here will let you do that in a single step and you can also run it in full screen mode.

 Compatible with the following Windows OSs:

  • Windows 11 Pro 64-bit
  • Windows 10 Pro 64-bit
  • Windows 8 Pro 64-bit
  • Windows 7 64-bit
  • Windows Vista 64-bit
  • Windows XP 64-bit

Download the setup file and install it, then run the program through the shortcut to start coding.

Install TASM 5.0 32-bit version

Categories
Uncategorized

Create a robots.txt file for your Site or Blog

Creating a robots.txt file for your site is very easy, even for beginners. You don’t have to know anything about Search Engine Optimization(S.E.O) to do this. Setting your own robots.txt file lets you communicate with the search engine bots on the Internet that crawl your site for fresh content regularly. This is how my robots.txt file looks like:

#Created by www.CollegeStash.com do not remove this
sitemap: http://www.collegestash.com/sitemap.xml

User-agent:  *
# disallow all files in these directories
Disallow: /cgi-bin/
Disallow: /wp-admin/
Disallow: /wp-content/
Disallow: /wp-includes/
Disallow: /recommends/
Disallow: /go/
Disallow: /category/
Disallow: /tag/
Disallow: /tag/*
Disallow: /archives/
Disallow: /comments/feed/
Disallow: /trackback/
Disallow: /index.php
Disallow: /xmlrpc.php
Disallow: *?wptheme
Disallow: ?comments=*
Disallow: /search?
Disallow: /?p=*

Disallow: /wp-content/plugins/

User-agent: Mediapartners-Google*
Allow: /

User-agent: Googlebot-Image
Allow: /wp-content/uploads/

User-agent: Adsbot-Google
Allow: /

User-agent: Googlebot-Mobile
Allow: /
#Created by www.CollegeStash.com do not remove this

You can copy the text above, paste in your file text file and name it as robots.txt and then upload it to the root directory of your server(The directory where you have index.php or index.html files of your Site). You can also download this file and edit the existing sitemap URL with yours and  upload it directly to your root folder. The robots.txt of anysite is available directly and can be copied but I advice you to do it on your own cause it won’t take much of your time.

Understanding the commands

Allow /
As the name itself suggests, this command allows the bots to crawl the particular sub-directory of your Site if mentioned.

Disallow:
/feed

This command blocks the bots from crawling the “feed” sub-directory of your Site.

Sitemap: http://www.collegestash.com/sitemap.xml
This command allows the search engine bots to crawl your site through your sitemap, given explicitly in the command.

# This is a comment, i.e., the text after this symbol on the same line will not be read by the bot.
This # symbol is used for single line comments, and any text following it is a comment in the robots.txt file.

 What is a robots.txt file

The robots.txt file is used to tell the search engines which part of your site they should be crawling and which part they shouldn’t crawl. For privacy and security related issues people would like to exclude few areas of their website or blog from the search engines because they don’t want their private data to be indexed in a popular search engine like Google, so that everyone can access it. The search engines all over the Internet use bots to crawl the web and index new content onto their databases. This robots.txt file is useful in communicating directly with the bots or crawlers of the search engines.

Advantages of having your own robots.txt file

It is a good technique in S.E.O. to have a robots.txt file for your site as it helps you in blocking the search engine crawlers where you don’t want to have them. To grab the robots.txt file of any site just use this line in your address bar http://www.sitename.com/robots.txt ( For Example: https://www.facebook.com/robots.txt ).

If you have any problems regarding this, then please feel free to mention them in the comments section below.

Categories
Uncategorized

Transfer files via WiFi from PC to Android (Wireless): Websharing Lite

In today’s lesson, we will show you how to easily transfer files between Android and your computer. Best of all, we’ll show you how to transfer the files via WiFi without the hassle of having to look for a USB cable or removing the SD card from your Droid. You can follow along on the lesson via the Video tutorial or scroll down to the bottom for the Step-by-Step instructions.


There’s a lot of different ways to get files to/from your Android device to your computer. But I’ve been searching for the easiest method possible, so that I could teach users of all levels how to do it in a matter of minutes. Luckily, I was able to find a great app that makes transferring files between Android and your computer extremely simple. The app is WebSharingLite and it allows you to connect your Android device and computer together via the WiFi network in your home and/or office. There is no set up needed, just run the WebSharingLite app and it tells you exactly what to enter into any web browser’s URL bar to get there. You’ll then be able to upload/download whatever files you need. File sharing on Android has never been simpler than this! Take a look at the video tutorial below and let us know if you have any questions!

Also read: Battery Doctor – A real Battery Saving app

Step-by-Step Instructions for Websharing Lite

  • Go to the Android Market Store
  • Search for “WebSharingLite” app
  • Install the “WebSharingLite” app by NextApp, Inc.
  • Launch the App and click on the Start button at the bottom left
  • WebSharing will then be activated and you can go to your PC and type in the URL displayed on the screen into your web browser. If prompted, enter the password listed on the screen.
  • That’s it! Start transferring the files you need!
  • WebSharingLite not working properly for your device? Try this other great app that is very similar, WiFi File Explorer.
Categories
Uncategorized

Earn money from YouTube: How to link your Adsense account to Monetized videos

Monetizing your videos on YouTube is one part of starting your earning process, whereas linking your Adsense account to it is another. You can monetize your videos but you need a working(fully activated) Adsense account to earn money from YouTube content owned by you.

Make sure you already have the following

  • YouTube account
  • Monetized videos
  • Approved Adsense account

Monetization

  • Your uploaded videos need to have original content that is completely owned by you including the audio.
  • You should have a minimum number of subscribers.
  • Your account needs to be active for a particular period of time.

Once you get options to monetize your videos, all you will need is an Adsense account that is already active. Note that you wont be able to make much money unless you have a lot of subscribers and are getting a lot of regular views on your channel.

Linking Adsense to YouTube

Now coming to the second part, go to monetization in YouTube account and click on Add an Adsense account and associate your Adsense account with your YouTube account as shown below or if you have already associated an account and want to change it, then also it is feasible.

The money earned by this type of Adsense is nothing but the “Hosted Adsense” earnings that is displayed in your Adsense account Dashboard. It also includes a Blogger blog and it’s earning if you have one linked to your Adsense Publisher ID.

To learn how to get your Adsense account approved click here to read this.

If you have any queries then please feel free to ask me in the comment section below.

Categories
Uncategorized

Adobe Dreamweaver Cloud Shortcuts

Adobe Dreamweaver is an Industry-leading Web Design Software. Adobe Dreamweaver shortcut keys make life easier for the user. 

SHORTCUT KEYS

INSERT
Single Line Break <br />Shift-Enter
Non-Breaking Space ( )Ctrl-Shift-Space
Line BreakShift-Return
ImageCtrl-Alt-I
TableCtrl-Alt-T
Modify
Quick Tag EditorCtrl-T
Show Code NavigatorCtrl-Alt-Click
Working with Tables
Select individual (or multiple, discontinuous) table cellsCtrl-click cell(s)
Select Table (with cursor inside the table)Ctrl-A (may need to do twice)
Insert RowCtrl-M
Insert ColumnCtrl-Shift-A
Delete RowCtrl-Shift-M
Delete ColumnCtrl-Shift-hyphen(-)
Merge Selected CellsCtrl-Alt-M
Split Cell…Ctrl-Alt-S
Increase Column SpanCtrl-Shift-]
Decrease Column SpanCtrl-Shift-[
Add new row at bottom of tablewith cursor in bottom right table cell, hit Tab
working with Frames
Add a new frame to framesetIn the Frames panel select the frame, then in the document window Alt-drag frame border
Pull out solid frame (creates Nested Frameset)Ctrl-drag frame border
Select a frameAlt-click in frame
Select next frame or framesetAlt-Right arrow
Select previous frame or framesetAlt-Left arrow
Select parent framesetAlt-Up arrow
Select first child frame or framesetAlt-Down arrow
working with Images
Replace image with a different oneDouble-click image
Edit image in external editorCtrl-Double-click image
working with Divs
Select a div (without having to click its grab tag)Ctrl-Shift-click
working with Links
Make Link…Ctrl-L
Remove LinkCtrl-Shift-L
Open the link-to document in DreamweaverCtrl-Double-click link
Drag & drop to create linkSelect the text, then Shift-drag it to file in Site panel
Formatting Text
NoneCtrl-0
Heading 1Ctrl-1
Heading 2Ctrl-2
Heading 3Ctrl-3
Heading 4Ctrl-4
Heading 5Ctrl-5
Heading 6Ctrl-6
ParagraphCtrl-Shift-P
Left …Ctrl-Alt-Shift-L
CenterCtrl-Alt-Shift-C
RightCtrl-Alt-Shift-R
JustifyCtrl-Alt-Shift-J
Text IndentCtrl-Alt+]
Text OutdentCtrl-Alt+[
Document Editing
Go to Next WordCtrl-Right arrow
Go to Previous WordCtrl-Left arrow
Go to Previous ParagraphCtrl-Up arrow
Go to Next ParagraphCtrl-Down arrow
Select Until Next WordCtrl-Shift-Right arrow
Select From Previous WordCtrl-Shift-Left arrow
Select From Previous ParagraphCtrl-Shift-Up arrow
Select Until Next ParagraphCtrl-Shift-Down arrow
Edit TagShift-F5
Exit ParagraphCtrl-Enter
Code Editing
Show Code HintsCtrl-Space
Quick Tag EditorCtrl-T
Select Parent TagCtrl-[
Select ChildCtrl-]
Balance BracesCtrl-’
Find Next (Find Again)F3
Select line up/downShift-Up/Down arrow
Character select left/rightShift-Left/Right arrow
Select to page up/downShift-Page Up/Page Down
Move to word on left/rightCtrl-Left/Right arrow
Select to word on left/rightCtrl-Shift-Left/Right arrow
Move to start/end of lineHome/ End
Select to start/end of lineShift-Home/End
Move to top/end of fileCtrl-Home/End
Select to start/end of fileCtrl-Shift-Home/End
Go to LineCtrl-G
Indent CodeCtrl-Shift->
Outdent CodeCtrl-Shift-<
View
Switch between Code and Design ViewsCtrl-` (that’s the ~ key)
Switch All Windows to a Specific ViewCtrl-Click Code or Design View Button
Switch between Documents (Tabs)Ctrl-Tab
Refresh Design ViewF5
Live ViewAlt-F11
Working with Documents & panels
Show/Hide PanelsF4
Switch to Next Document (Tab)Ctrl-Tab
Switch to Previous Document (Tab)Ctrl-Shift-Tab
BehaviorsShift-F4
BindingsCtrl-F10
Code InspectorF10
ComponentsCtrl-F7
CSS StylesShift-F11
DatabasesCtrl-Shift-F10
Files.F8
FramesShift-F2
HistoryShift-F10
AP ElementsF2
PropertiesCtrl-F3
ReferenceShift-F1
ResultsF7
Server BehaviorsCtrl-F9
SnippetsShift-F9
Tag InspectorF9
Misc
Check SpellingShift-F7
Get File from ServerCtrl-Shift-D
Put File on ServerCtrl-Shift-U
Categories
Uncategorized

CPU Fan Error! Press F1 to Resume, FIXED!

CPU Fan Error
A lot of people might have experienced the same boot error mentioned here in this post.
” CPU Fan Error!
Press F1 to Resume

This could be caused by a few issues.
1. THE FAN IS NOT SPINNING
If this is the case, we have to agree with the BIOS message, and face the sad truth that our fan might be broken, it can also be the fan header on the motherboard itself. To test this, try connecting your fan to another port, if the fan spins, it is probably the connector on the motherboard. If it does not spin, you will probably have to buy a new fan.
2. THE FAN IS SPINNING
If the fan is spinning, and you are certain the fan is connected to the right socket. You should consider the following things:
    (a) If the problem came out of no where, the fan might have collected a lot of dust, making it hard for the fan to get up to speed during boot.
    (b) If the problem started after some meddling with the hardware, the problem could be like (a), but it could have made a change in the BIOS. Eg. Most ASUS motherboards require 600 RPM during boot, for INTEL and 800 RPM for AMD. This could easily have been decreased without you noticing it.

To rectify this problem, you should open your BIOS settings and go to something like a “Hardware Monitor” section, in the BIOS settings, or where
ever, you can find CPU fan speed settings. The CPU Fan Speed might say “N/A”, change this to ignore. Which will make the motherboard ignore the current RPM of the CPU fan during boot.

In some cases you will be able to also Disable the CPU Q-Fan Control. However this might cause your fan to burst with full throttle all the time, and you will have to face a lot of unnecessary noise.

If you have anything to add then please feel free to leave a comment. Thank you for reading.

Categories
Uncategorized

Google Adsense Approval Tricks & Do’s and Don’ts!

With every coming day the approval of Google Adsense is getting tougher, so I decided to take an insight into all the things you need to know about getting your site or blog approved for the best Adsense available out there.

Minimum steps to get approved by Google Adsense 2013 – Stage 1

  • Register your site or blog a domain name with a .com or a .org or a .net etc.
  • Make sure you have an e-mail that looks like this: admin@yourdomainname.com.
  • Make sure you have atleast 20 posts with original quality content, that is well formatted.
  • Should have atleast 100-200 visitors per day 2 days before submission of your blog(This you can make sure that you drive visitors from Social Networking sites like Facebook, twitter, Google+, etc).
  • Minimum website registration time is 2 days on an average before submission to Google.
  • Don’t include any age restricted content on your site as Google Adsense strictly prohibits doing this.

These steps will make sure you qualify for stage 1 of Adsense. After stage one you will see this once you login to your Adsense account,
“Your application is still being reviewed. You will see only the background of your web page instead of live ads until your account has been fully approved.”

Google Adsense 2013 – Stage 2

  • You will have to create an ad-unit and copy paste the code of the ad-unit that you have created into your website or blog.
  • Google will take a maximum of 2-3 days time to crawl and go through your site after you finish the above step.
  • Make sure you do not ask your users or viewers to click on your ads as google doesn’t support any word stronger than ” Our Sponsors ” for their ads.
  • Make sure your content is oriented to the particular field of interest that your registered domain name suggests.
  • After your account passes the stage 2 then only the Red banner will be removed from your adsense account.

After following the above steps you should have been approved my Google Adsense Program.

Do’s

  • Link your google adsense account to your Youtube account if you have you video to upload for your viewers.
  • Create your google custom search engine for your site, then link your adsense account to it with your publisher-id and display ads above the search results.
  • Using the word ” Sponsors ” above your ads will help upto an extent.
  • If you have any Android Applications then you can link them to your adsense account.
  • Use the same adsense code for your other sites that comply with the Google Adsense Policy.

Dont’s

  • Do not click and do not ask your users or viewers to click on yours ads anywhere on the Internet, as google will disable your account for violating their rules of agreement by banning it.
  • Do not take a picture of your google adsense account with the publisher-id visible and post and share it.
  • Do not post abusive posts or adult content.
  • Do not do anything that violates the License of agreement with google.

 

Quick Adsense Tricks & Why you shouldn’t opt for them in the long run

There are many third-party sites out there that get you can Adsense account in no time, but using that for your website results in a success rate of 0.5% in the long run. The sites are docstoc, bharatstudent, etc. For example, uploading a few documents and sending your account for approval through docstac seems like an easy process to get approved, but that account will only stay alive for a few days. For it to stay alive you will hvae to keep contributing regularly to the site you registered by uploading your documents regularly which is a painful task when you start earning through Adsense.

You can buy Adsense account for as low as 5$ on the Internet through websites like Fiverr.com, where you will just have to type in “adsense account “(the other keywords wont work as I have already tried them). Then select the user you find with the best ranking and highest reputation and recent comments on his work and pay him through paypal. They will guarantee you an approved Adsense account in 1 day as they use the same method that is mentioned above.

Learn how to link your Adsense account to your YouTube account.