home | contact us
» » February


I’m going down to London tonight because tomorrow is the PHP UK Conference of 2009.

Looking forward to it :-)

http://www.phpconference.co.uk/


 

I recently had a really strange issue with Open Suse 11 – the contents of my home directory were totally invisible if using the file manager.

I could see them in the terminal, however I was only able to run the ls -al command as root. If I did it at my normal user level, it just hung.

After a load of reading around it seems that the culprit may well have been dodgy files in the /tmp folder.

So I removed all of the files in the /tmp folder using the command

rm -R /tmp/*

And then restarted and it now seems to be working fine.

However, I still haven’t figured out the NetworkManager problem and have to manually start NetworkManager on every boot.


 

On a forum I frequent the discussion came up of guaranteed number one positions in Google.

My argument here is that its easy enough to get to position number one for “something” – for example Fnargleblarglewobbady

The question is whether the search keyword or phrase is one that there is any worth in being number one for. That all boils down to how often it gets searched for. I am guessing that this post will get to number one for Fnargleblarglewobbady as no one has searched for it.


 

Check this out – chromium (the open source backbone of Google Chrome) running on Linux, courtesy of the nice people at Code Weavers

More…


     

    A common mistake made with Magento installations is that the the standard theme (eg default) is customised to suit the look of the site but is still kept in a folder called default. If you do this then whenever you want to upgrade your Magento store, the theme folder will be overwritten causing you all kinds of problems. I hope you had a backup!

    All you need to do is make sure that if you are running a custom theme – even if it is simply a modified version of the default theme, make sure that it is set up a separate theme with it’s own name. This way you will be able to upgrade Magento without too much theme problems.

    We never recommend applying a Magento upgrade to a live site, instead set up a password protected dev subdomain which has a fully functional copy of your store. You can then test out upgrades on this version first, sort out any problems and then only update the live site once you are happy it will work fine.

    Edmonds Commerce specialise in helping ecommerce businesses set up or migrate to a Magento based solution – get in touch today.


     

    If your Open Suse 11.1 network isn’t working and you have the message NetworkManager isn’t running.

    You need to start NetworkManager

    $ su
    $ NetworkManager
    

    This gets your network up again, but it’s a pain. I’m still looking for a proper fix and will update this post when I do.


     

    If you are feeling lazy, or would like to build in some future proofness into your system, you can use the MySQL Desc query to get table column information and then use this information to create dynamic SQL insertion strings.

    For example:

    $cols_query = db_query("desc table");
    while($cq = mysql_fetch_assoc($cols_query)){
    	$cols[]=$cq;
    }
    foreach($cols as $c){
    	if(!empty($_POST[$c['Field']])){
    		$sets[] = $c['Field'] . " = '" . mysql_real_escape_string($_POST[$c['Field']]) . "'";
    	}
    }
    mysql_query("insert into table set " . implode(', ', $sets));
    

     

    My MySQL dump splitting script has come in handy countless times. Recently I also needed to remove keys from an SQL dump to enable me to import a dump that had keys associated with text columns.

    Here is the updated script

    *note – now updated again to strip out any drop table statements if splitting

    <?php
    /*MySQL Dump Split to Tables
    * script supplied by Edmonds Commerce
    
    * www.edmondscommerce.co.uk
    * if you like it, please link back with a do-follow
    * 
    * Now updated with better regex and also the ability to strip out keys other than the primary
    */
    echo '<h1>MySQL Dump Split to Tables + Remove Keys</h1>';
    set_time_limit(600);
    if(!isset($_GET['dump_file'])){
    	echo '<form><b>Dump File Path:</b> <input name="dump_file"> <input type="submit" value="go"><select name="operation"><option value="split">split by tables</option><option value="keys">remove keys other than primary</option><option value="both">both</option></select></form>';
    }else{
    	if(preg_match('%keys|both%', $_GET['operation'])){
    		$contents = file_get_contents($_GET['dump_file']);
    		$pattern = '%,(s+?)KEY(.*?))%si';
    		$nokeys = preg_replace($pattern, '', $contents);		
    		$_GET['dump_file'] = 'nokeys.sql';
    		file_put_contents('nokeys.sql', $nokeys);
    	}
    	if(preg_match('%split|both%',$_GET['operation'])){
    		echo '<h3>Splitting File</h3>';
    		flush();
    		$handle = fopen($_GET['dump_file'], "r") or die('failed openeing source file ' . $_GET['dump_file']);
    		if ($handle) {
    			while (!feof($handle)) {
    				$line = fgets($handle);	
    				if(preg_match('%^drop table(.+?);%i', $line)){
    					continue;
    				}					
    				if(stristr($line, 'CREATE TABLE')){
    					echo '. ';
    					if(isset($out)){
    						fclose($out);
    						unset($out);
    					}
    					preg_match('%CREATE TABLE (<code>|)(w+)(</code>|)(s+)($%i', $line, $matches);
    					$table_name = $matches[2];
    					$out = fopen('output/'.$table_name . '.sql', 'w') or die('failed to create file ' . $table_name . '.sql');
    					fwrite($out, $line . "n") or die('failed writing to file ' . $table_name . '.sql');
    				}else{
    					if(isset($out)){
    						fwrite($out, $line . "n");
    					}
    				}		
    			}
    			fclose($out);
    			fclose($handle);
    		}else{
    			echo 'no handle on file - does it exist - permissions...';
    		}
    	}
    }
    echo '<h1>Done</h1>'
    ?>
    
    

    More…

    Updated MySQL Dump Splitter and Cleaner | Edmonds Commerce Blog
    Branedy » Blog Archive » WordPress MySQL exercises
    Python Script to Backup MySql Databases (WordPress or other databases)
    Importing Large MySQL Databases With BigDump
    MySQL Upgrade: 1and1 is not the best host in the world | TheGarage


     

    If you are extremely puzzled with MySQL error messages relating to the number 2147483647, this is actually because you are trying to use an integer number higher than 2147483647 and MySQL’s maximum integer value is 2147483647.

    more info


     

    Check out this excellent introduction to debugging Zend Framework applications using FirePHP.


     
    rss icon