Archive

Archive for the ‘database’ Category

Replace line break with

March 1st, 2010 admin No comments

This code is used to replace line break saved in database to
in html display

$astring = str_replace(chr(13) . chr(10), "", $astring);
Categories: database, programming Tags: ,

Problem uploading big sql file via phpMyAdmin

November 11th, 2009 admin No comments

I faced problem uploading a huge sql file to my shared hosting server. The size was not that big. It was only 1.8MB in size with about 30,000 records but phpMyAdmin (provided in cpanel) still failed to fully upload and run the file.

I then googled for a solution.

One of the solutions suggest to use SSH but I’m not familiar with it.

Another solution is by using mysqldumper but the configuration seems quite tedious.

Then I found another solution called BigDump which is very straight forward. You upload a PHP script together with your huge sql file via FTP. Then just run the PHP script as usual. In a second all the data has been restored in your database.

SQL statement to list duplicate contents

July 10th, 2009 admin No comments

You will need this SQL statement to list all duplicate contents in a table

SELECT email,
COUNT(email) AS NumOccurrences
FROM users
GROUP BY email
HAVING ( COUNT(email) > 1 )

source

Categories: database Tags: , , ,

How to backup MySQL table in phpMyAdmin

July 9th, 2009 admin 2 comments

Sometimes when you are going to execute an SQL statement to your production database, you need to be very careful especially when you are using DELETE or UPDATE command.

To ensure your original data will be available, you can backup the whole table that you are going to do the operation.

To backup the whole table is very easy in phpMyAdmin (even in other SQL tool).

phpmyadmin

After you done with the operation and it is successful, you can easily drop the temporary backup table.

Categories: database Tags: , ,