Get Auto Increment value from MySQL table

Many a times we require the next Auto Increment value from a MySQL table. Most of the people would do something like this:

$query = "Select MAX(id) from users";
$res = mysql_query($query);
$row = mysql_fetch_assoc($res);
$maxid = $row['MAX(id)'];
echo $maxid;

This would give correct results but if we delete the latest row, it will start to give wrong results.

We’ve got another query which can be used to get correct ‘Auto Increment’ values from the table.

$query = "SHOW TABLE STATUS LIKE 'users'";
$res = mysql_query($query);
$row = mysql_fetch_assoc($res);
$maxid = $row['Auto_increment'];
echo $maxid;

This will always give correct values for Auto Increment.

Re-detection of DMA mode in windows xp

My desktop computer was running extremely slow but it wasn’t like this before. Even formatting didn’t help, so I knew for sure that there was a problem with hardware. I was right on that, DMA mode wasn’t being detected by XP.

For your knowledge, DMA (Direct Memory Access) is a mode supported by modern hard-disks/DVD drives for much faster access times to device. To check if your HDD’s working on DMA mode, follow these steps:

1. Open Device Manager.

2. Expand IDE ATA/ATAPI Controllers to display the list of controllers and channels.

3. Right-click the icon for the channel to which the device is connected, select Properties, and then click the Advanced Settings tab.

4. Check the Current Transfer Mode: If it is in PIO mode, that means that it isn’t working in DMA mode. Try selecting ‘DMA if available’ from Transfer Mode and restart and recheck if the mode changes to DMA. If it doesn’t change, that means either your HDD doesn’t support DMA mode or the registry entries need to be deleted so that Windows XP redetects the mode on startup.

Automatic method for deletion of registry keys:

Download this vbs script:
Link

Execute the script and everything will be done automatically. This is the recommended method.

Source: http://winhlp.com

Manual method for registry keys deletion:

1. Open RegEdit.

2. Navigate to the following KEY:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E96A-E325-11CE-BFC1-08002BE10318}\

3. It will have subkeys such as 0000, 0001, 0002, 0003, and so on.

4. Inside each key, delete all entries of the following values:
MasterIdDataChecksum
SlaveIdDataChecksum

5. Restart the computer. Windows should now redetect the DMA settings.

[Solved] Absolute positioning and screen-resolution problem

Absolute positioning is great for positioning items anywhere on a page but it does not mix well with screen-resolution. It might look fine on your resolution but it might look completely different on another resolution. Element placement changes upon changing the screen resolution or even when resizing the browser window. It is because items positioning is measured from the browser’s window.

To always display it correctly, you can put relative or absolute positioning on the parent element.

Eg:

Hello World!

	

Edit registry without windows

Many a time you will want to edit your registry when you get your windows screwed and it refuses to boot up.
You know what changes should be made in the registry to fix the problem, but you don’t have any way to fix it. I had a similar problem and I used this tool to edit registry:
http://home.eunet.no/pnordahl/ntpasswd/main.html

This is a non-GUI bootable app. You should be familiar with the command-line and how it works before using it otherwise you may get into deeper problems.

This is another tool which I found while googling:

http://www.pcregedit.com/

I hope this helps all you people who are thinking to reformat your computer because of registry errors.

Peace!

Debugging Javascript In Internet Explorer

Internet explorer has always been a programmer’s nightmare. You have finished a wonderful looking site, full of javascript effects just to find out that it doesn’t work in Internet Explorer. Its a real pain in the neck to find out which part of the script is causing errors in Internet Explorer.

In Firefox, we have tons of debugging option including the default error-console, firebug, etc which are very good tools. But in IE, the default error reporting mechanism shows wrong line no. most of the time, so its pretty useless.

I searched for debugging tools for javascript in IE and came across JS Companion. Its a pretty good addon for IE which can help you debug javascript easily. It solved my problems in seconds. They also have other addons for IE which gives pretty much same functionalities as firebug gives in FF but they aren’t free.

Peace!