Saturday, January 29, 2011

Maximum length for MySQL TEXT data types

MySQL supports 4 TEXT data types, TINYTEXT, TEXT, MEDIUMTEXT and LONGTEXT.

TEXT data types are also able to store much more data than VARCHAR and CHAR text types so TEXT types are what you need to use when storing large amount of content in a database table.

The maximum amount of data that can be stored in TEXT data types are as follows:

TINYTEXT 256 bytes
TEXT 65,535 bytes (64kb)
MEDIUMTEXT 16,777,215 bytes (16MB)
LONGTEXT 4,294,967,295 bytes (4GB)


- Payal Maru
Team Lead - J2EE Application Development
NAVSYA Technologies Pvt. Ltd.
www.navsya.com

mySQL Database Backup and Import

For mySQL database backups use following commands:

c:\>mysqldump -u [USER] -p -P [PORT] --all-databases > [FILE]

For example, the command will look like this:

c:\>mysqldump -u root -p -P 3306 --all-databases > mydump.sql

After you press enter you will be asked for password and then your backup file will be created.

You can also choose to export/backup only select databases.


For restoring the backup:

mysql -u root -p -P 3306 < mydump.sql

Note that in this case while restoring the databases all the existing databases / tables with the same names will be dropped and recreated with the data in the dump file.

Note: If your mySQL bin directory is not specified in the PATH variable you will need to go to the directory where mySQL is installed and then fire this command


- Siddhesh Prabhu

Team Lead - J2EE Application Development
NAVSYA Technologies Pvt. Ltd.
http://www.navsya.com

Multiple File Upload with PHP

Use following code to provide a functionality to upload multiple files from a single form.

Create HTML form as mentioned in the code below:

<html>
<body>
<form action="addPhotoAction.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="rowCount" id="rowCount" value="2">
<table>
<tr>
<td>Photo 1</td>
<td><input type="file" name="photo0" id="photo0"></td>
</tr>
<tr>
<td>Photo 2</td>
<td><input type="file" name="photo1" id="photo1"></td>
</tr>
</table>
</form>
</body>
</html>



Copy & paste following code to create addActionPhoto.php:


<html>
<body>
<?php
$rowCount=$_POST[‘rowCount’];
for($i = 0; $i < $rowCount; $i++) // where rowCount is the No. of uploads
{
$target_path = "FolderName_to_store_images/";
$target_path = $target_path . basename( $_FILES[photo'. $i]['name']);

$file_name = stripslashes($target_path);
$file_name = str_replace("'","",$file_name);
$copy = move_uploaded_file($_FILES[photo'. $i]['tmp_name'],$file_name);

// prompt if successfully copied
if($copy!="")
{
//here comes the insert query
echo “Images uploaded successfully.<br>”;
}
else
{
echo "$file_name | could not be uploaded!<br>";
}
}
?>
</body>
</html>


NAVSYA Technologies Pvt. Ltd.
www.navsya.com

Friday, January 28, 2011

jQuery Calendar / Widgets are displaying too large?

If you are facing an issue where your jQuery widgets are getting displayed too large, try this simple solution.

Just add the following lines of code to your HEAD tag:

#ui-datepicker-div { font-size: 12px; }


- Siddhesh Prabhu
Team Lead - J2EE Application Development
NAVSYA Technologies Pvt. Ltd.