Archive for the ‘MySQL’ Category

Importing large databases on Wamp5 PHPmyAdmin, how?

Tuesday, August 24th, 2010

Have a database bigger than 2MB? want to import them somewhere else? but you cant and PHPmyAdmin just gave you the dead end message below?

No data was received to import. Either no file name was submitted, or the file size exceeded the maximum size permitted by your PHP configuration. See FAQ 1.16.

Have no fear, there’s a solution:

Look for the php.ini file -> c:/wamp/www/apache2/bin/php.ini

Then change the following lines:

post_max_size = 8M
upload_max_filesize = 2M
max_execution_time = 30
max_input_time = 60
memory_limit = 8M

To these new values:

post_max_size = 100M
upload_max_filesize = 100M
max_execution_time = 5000
max_input_time = 5000
memory_limit = 100M

Then restart wamp5 and retry importing…

Happy coding :P

Formatting output of datetime MySQL value

Monday, February 22nd, 2010

I wanted to give a new output for those ugly looking datetime values in MySQL, which we get by using NOW() function in INSERT.

Why? because it pretty darn ugly, unpresentable and robot like.

Ok ok, maybe that’s description overkill for datetime, but how would you like this “2010-02-14 11:12:58″ to look like this “February 14, 2010″.

Pretty readable that the later huh.

Ok enough blah blah, here is my function, feel free to abuse it. :)

function Format_Date($date){
	$mos=array('01'=>January,'02'=>February,'03'=>March, '04'=>April, '05'=>May, '06'=>June, '07'=>July, '08'=>August, '09'=>September, '10'=>October, '11'=>Novermber, '12'=>December);
	$d = explode(" ",$date);
	$n = explode("-",$d[0]);
	return $mos[$n[1]].' '.$n[2].', '.$n[0].' '.$d[1];
}

To use this function:

$query=mysql_query("SELECT datetime FROM table"); //2010-02-14 12:11:03
while($row=mysql_fetch_assoc($query)){
echo Format_Date($row[datetime]);//February 14, 2010
}

Easy right? fell free to post your customizatios :)