server not sending emails?

$> netstat -tanl|grep :25

should output

tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
tcp 0 0 ::1:25 :::* LISTEN
test php mail
Put Php into interactive mode

$> php -a
$> mail(‘your@emailaddress.com’, ‘subject’, ‘content’);

Is mail daemon running?

restart

$>postfix stop && postfix start

Advertisements

Magento: How to get current url

$currentUrl = Mage::helper('core/url')->getCurrentUrl();

For example:

homepage = http://local.mag17/
product page = http://local.mag17/index.php/sony-vaio-vgn-txn27n-b-11-1-notebook-pc.html

ERROR 1701 (42000): Cannot truncate a table referenced in a foreign key constraint

As part of testing Magento’s order workflow I needed to truncate the sales tables.

However, Mysql complained with the following error:
ERROR 1701 (42000): Cannot truncate a table referenced in a foreign key constraint

However, by switching of foreign key check, I was able to truncate the table.

SET FOREIGN_KEY_CHECKS=0;
TRUNCATE table1;
TRUNCATE table2;
SET FOREIGN_KEY_CHECKS=1;

source: http://stackoverflow.com/a/8074510

MySql dump only tables with partial name

mysqldump -u <username> <database> $(mysql -u<username> -D <database> -Bse “show tables like ‘sales%'”) > <dumpfile.sql>

Javascript redirect on page load using prototypejs

First option using href

Event.observe(window, ‘load’, function() {
window.location.href = “http://stackoverflow.com&#8221;;
});

However a better way is to use replace method.

Event.observe(window, ‘load’, function() {
window.location.replace(“http://www.google.co.uk&#8221;);
});

“because replace() does not put the originating page in the session history, meaning the user won’t get stuck in a never-ending back-button fiasco. If you want to simulate someone clicking on a link, use location.href. If you want to simulate an HTTP redirect, use location.replace.” http://stackoverflow.com/a/506004

Tagged ,

Retrieve the number of tables in a mysql database

To find out the number of tables in a particular mysql database, you can use the following sql statement.

SELECT count(*) from information_schema.tables WHERE table_schema = 'dbname';
Tagged
Advertisements