Skip to main content

Posts

The easiest way to validate an email address in php and html

 The easiest way to validate an email address in php and html <?php if (filter_var('email@myemail.it', FILTER_VALIDATE_EMAIL) === false) { echo ' wrong email'; } ?> via html just use the type "email" for your input and the browser will do the rest if you don't have particular needs. Required will make your input mandatory.   <input type="email" name="email" required> Never use only client side validations/checks.

Call to undefined method Mage_Core_Model_Config::cleanCache app/code/core/Mage/Core/Model/App.php on line 1088

 Call to undefined method Mage_Core_Model_Config::cleanCache app/code/core/Mage/Core/Model/App.php on line 1088 If you have a very old version of magento and/or you have lost files or you've updated only the library this error can happen (as happened to me). Add this code     /**     * Configuration cache clean process     *     * @return Mage_Core_Model_Config     */     public function cleanCache()     {         return $this->reinit();     }     in app/code/core/Mage/Core/Model/Config.php. after the function reinit() - around line 600 in magento 1.3.1 References http://phpcrossref.com/xref/magento/app/code/core/Mage/Core/Model/Config.php.html#cleancache

Magento folders that must be writeable - magento files permissions - chmod magento folders.

Magento folders that must be writeable - chmod magento folders. The folders/files that must be  writeable (chmod 777 with subfolders) in magento are: /yourrootfolder/var/ used by magento for the cache, reports, logs /yourrootfolder/media/ used by magento for the images /yourrootfolder/app/etc/ ONLY for OLDER magento version prior to 1.4 to update use_cache.ser only (afaik).

Fix c:\windows\system32\drivers\etc not resolving hosts to ip address.

Fix c:\windows\system32\drivers\etc not resolving hosts to ip address. Before starting make sure that you have already modified correctly your %SystemRoot%\System32\drivers\etc\hosts file Verify that the path is your registry is pointing to the correct path HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DataBasePath The default value should be %SystemRoot%\System32\drivers\etc Check that you are resolving correctly by using the ping command, it will show the resolved ip address even if unable to ping. Don't use nslookup since it seems to ignore the hosts file by default. Run (theorically useless ... but who knows) this command to flush the nameservers ipconfig /flushdns If you are using a browser remember to clear all your cache. Verify that the hosts file have no extensions, just "hosts". Make sure that there are no special characters inside the file. If it's a system issue run sfc /scannow Another possibility is...

Get the ID of latest updated rows and automatically update latest modification timestamp

If you want to get the IDs of the latest updated rows it during a query you can do something like that SET @updatedrows := null; /*we will store here the IDs*/ UPDATE mytable SET coltoupdate = 'mycontent' WHERE myID > 5 AND (SELECT @updatedrows := CONCAT_WS(', ', myID, @updatedrows)); SELECT @updatedrows; /*shows the updated IDs*/ If the rows have already been updated via other queries that you are not aware of you, as far as I know, you must have a column (ex. lastmodified) in the database that must be updated each time that you do modifications. To have *automatic* modifications it's better to use the triggers, if supported by your mysql version. (https://dev.mysql.com/doc/refman/5.0/en/create-trigger.html ) /*adding the lastmodified col to the table*/ ALTER TABLE mytable ADD lastmodified DATETIME NOT NULL; /*creating the trigger*/ CREATE TRIGGER updatelastmodified BEFORE UPDATE ON `mytable ` FOR EACH ROW SET NEW.lastmodified = NOW(); After ...

How to replace the definer Clause from Dump File Before migration in sql file dump

 How to Remove Definer Clause from Dump File Before Migrating a MySQL Database  if you have sed (for windows go to http://gnuwin32.sourceforge.net/packages/sed.htm ) available you can run  sed -E 's/DEFINER=`[^`]+`@`[^`]+`/DEFINER=CURRENT_USER/g' yoursqlfile.sql > outputsqlfile.sql  otherwise you can use on your preferred text editor as vim, notepad++ or emeditor (good for large files of several Terabytes) and  do a search/replace. search string: DEFINER=`[^`]+`@`[^`]+` replace string: DEFINER=CURRENT_USER  You can also remove the definer (empty string) instead of using your current user.