How to reset Auto Increment to a specific value in MySQL?

Once a column is set to Auto Increment the value would Increment by one for every record added. Therefore, the column value for each record would be unique and hence it could be set as a primary key. There may be times when you would want it to Increment from a specific value. This is how it can be done-

ALTER TABLE table_name AUTO_INCREMENT=1001;

 

In the above example, Auto Increment would begin from 1001 rather than 0.

 

Advertisements

PHP MYSQL Error Message-mysql_fetch_row expects parameter 1 to be resource-

mysql_1

This is an error that one faces when they use mysql and mysqli Interchangeably. Functions that begin with “mysql” are deprecated and no longer supported in the latest versions of PHP. So, one should either use mysql throughout the program or mysqli, mix and match doesn’t work. Mix and match might work in the grocery store that might help you to get sale prices but unfortunately it doesn’t work here! 😀

 

Pixlr: An Online Photo Editor

Pixlr: An Online Photo Editor

Whenever we think of photo editing, the first thing that comes to our mind is Photoshop. But, unfortunately Photoshop is something which not everyone can afford so they would have to look at some place else. One of the tools which they could take a look at is Pixlr.

Pixlr is an Online Photo Editor that can perform the basic editing functions like cropping, resizing, adding a white space etc. It may not have all the features of Photoshop and hence it is not a recommended substitute. But, with that said it is always good to give it a shot and see what you can achieve by playing around with it!

 

How to fetch the last ID from a MySQL Table and save it in a PHP Variable

When you are Involved in comparing and updating two different tables there may be times when you would need the last ID of a table so that it can be used in another table provided the ID is a primary key set to Auto Increment.

The way you would go about this is to use the max keyword to get the last ID of a table and then use the mysql_fetch_row function to fetch a row of data from the result handle. This value is then saved in a PHP Variable that can be later used for further manipulation. The overall code would appear to be something like this-

//Database Connection
$db = new mysqli($dbHost, $dbUsername, $dbPassword, $dbName);



//Get the Last ID of a table. The column name is "SNo"
$last_id = mysqli_query($db,"SELECT max(SNo) FROM Test4_HarvestData");




if (!$last_id) {

    die('Could not query:' . mysql_error());

}



//The Last ID saved in a PHP Variable
$row_sno= mysqli_fetch_row($last_id);


echo "<br>The Last ID is : ".$row_sno[0];

 

 

Get the Pocket App

Have you ever been in situations where you are trying to find an unfinished article on your phone that appears to be lost in a sea of browser tabs? Or if you are reading an article but half way through you realize that you don’t have enough time and decide that you are going to read it later but never come back to it again. Does this sound familiar?

I had been through these situations a lot and then I found an app where I could save articles that I want to read to the app and come back later and read them. This app saves all the articles that you want to read in one place so that it never gets lost. And another good feature about the “Pocket” App is that it is saved for Offline viewing. So, if you happen to catch the subway or the metro that primarily goes underground you can still read those articles.

pocket.jpg

 

The App is called Pocket and it is available on Android and iOS.