Skip to main content

Posts

Showing posts from January, 2012

Detecting the flash player version

If a user is using a browser with a flash player that is not upgraded, we can show him a message to upgrade his flash player.... using the swfobject javascript. The below code can show the upgrade message over the video, which is run using the jwplayer. <html> <head> <script type='text/javascript' src='jwplayer.js'></script> <script type="text/javascript" src="swfobject.js"></script> </head> <body> <div id="video_player"></div> <script type="text/javascript">     var so = new SWFObject('player.swf','flashContent','280','240','11');     so.useExpressInstall('expressInstall.swf');     so.addParam('allowfullscreen','true');     so.addParam('allowscriptaccess','always');     so.addParam('bgcolor','#FFFFFF');     so.addParam('allowfullscreen','true

php debugging

The simplest way to debug our php code is to write the data to a log file. For example, this code prints an array to a text file.... <?php $myFile = "logFile.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = '';                foreach($elem as $k=>$v) $stringData .= $k.'=>'.$v."\n";                fwrite($fh, $stringData); fclose($fh); ?> Dont forget to view the file in its stored location...

php array to xml example

This is an example of generating an xml output format from the database. This code is creating a sample rss feed from the joomla articles (which can be added to a rss.xml file). <?php     $dbhost = "localhost";     $dbuser = "root";     $dbpass = "";     $dbname = "joomla";     mysql_connect($dbhost,$dbuser,$dbpass);     mysql_select_db($dbname);     mysql_query("SET NAMES 'utf8'"); // to get proper format         $sql = "SELECT id, title, alias, title_alias, metadesc FROM `jos_content`     where catid=12 limit 3";     $q   = mysql_query($sql) or die(mysql_error());     $xml = "";     while($r = mysql_fetch_array($q)){       $xml .= "<item>";       $xml .= "<title>".trim($r['title'])."</title>";       $xml .= "<link>".trim($r['title_alias'])."</link>";       $xml .= "<pubDate>Fri