Thursday, February 2, 2012

IIF in php


Syntax 
(expr1) ? (expr2) : (expr3) 
If expr1 is True, THEN do expr2, ELSE do expr3.

Sunday, January 29, 2012

How to change default Apache page?

If you wanna change the home page for your apache server, you can change it easily in httpd.conf which is located in D:\XAMPP\apache\conf\ Just add your desired file to be an index page for your site. :) Good Luck and all the best.


<IfModule dir_module>
    DirectoryIndex xxxx.php index.php index.pl index.cgi index.asp index.shtml index.html index.htm \
                   default.php default.pl default.cgi default.asp default.shtml default.html default.htm \
                   home.php home.pl home.cgi home.asp home.shtml home.html home.htm
</IfModule>

Tuesday, January 24, 2012

Joomla 2.5 is now released with multi-database support and easy update notification.


Joomla 2.5 is now release with multi-database support and easy update notification.

New Key Features :
  • Multi-database support with addition of Microsoft SQL Server.
  • Automatic notification when a Joomla or extension update is available. When logged into the control panel, site administrators will instantly have access to new notification buttons that allows them to see and act on the latest updates. In addition to updates for the Joomla CMS, a second button offers third party extension notification updates.
  • A better natural language search engine to the Joomla core. Complete with auto-completion and stemming (for example if you type “running” in a search field you also see run), it is faster and more versatile than the standard search.
Joomla 2.5 is truly a collaborative community-driven software project developed with the feedback gathered from more than 2.5 million Joomla forum posts, 540,000 Joomla forum members and data from more than 8,800 Joomla extensions.  To download Joomla 2.5, go to http://www.joomla.org/download.html.

You can find the list of other new features in this release at New Features in Joomla 2.5

source : joomla.org



Tuesday, January 17, 2012

Uploading and Save CSV file in MySQL database with PHP

Uploading and Save CSV file in MySQL database with PHP


 <?php  
 include("opendb.php");  
 //echo isset($_POST['submit']);  
 if(isset($_POST['submit']))  
 {  
      $filename=$_FILES['files']['name'];  
      $filename=date('U').$filename;   
      $add1 = "import/$filename";   
      move_uploaded_file($_FILES[files][tmp_name], $add1);  
      chmod($add1,0777);  
      basename($_FILES['files']['name'] );   
      $filename1="import/$filename";  
      $fcontents = file ($filename1);   
      echo sizeof($fcontents);  
      for($i=0; $i<sizeof($fcontents); $i++) {   
      $line = addslashes(trim($fcontents[$i]));   
      $arr = explode("\t", $line);   
      echo "<pre>";   
      print_r($arr);  
 //exit();   
 //echo $arr;  
 $Repl_arr=array("[","]");   
 //echo $Repl_arr;  
 foreach($arr as $key=>$val)  
 {  
      $arr[$key]=str_replace($Repl_arr,"",$arr[$key]);  
      $arr_new=$arr[$key];  
      $arr_new1 = explode(",", $arr_new);  
 }  
 //echo "<PRE>";  
 //var_dump($arr_new1);  
 /*  
 $date=explode("/", $arr_new1[0]);  
 $dd=$date[0];  
 $mm=$date[1];  
 $yy=$date[2];  
 if(strlen($dd)==1){  
 $dd="0".$dd;  
 }  
 if(strlen($mm)==1){  
 $mm="0".$mm;  
 }  
 $date1=$yy."-".$mm."-".$dd;  
 */  
 $name=$arr_new1[0];  
 $addr = $arr_new1[1];  
 //$email=$arr_new1[2];   
 //$amount=$arr_new1[3];  
 $sql = "insert into mytestupload set   
 tfield='$name',tfield1='$addr'";   
 //echo $sql;  
 //exit();  
 $qr=mysql_query($sql);  
 echo "-----------1 Row Inserted----------";  
 $sql ."<br><br>\n";  
 if($qr!=0)   
 $msg= "Data has been imported";  
 if(mysql_error()) {  
 echo mysql_error() ."<br>\n";  
 }  
 }  
 unlink($filename1);  
 unset($_POST);  
 $_POST['submit']='';  
 $_POST='';  
 //echo "<script>window.location=('addcsv.php');</script>";  
 } ?>  
 <html>  
 <head>  
 <title>Import CSV</title>  
 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">  
 <link href="../css/decorate.css" rel="stylesheet" type="text/css">  
 </head>  
 <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">  
 <table width="100%" border="0" cellspacing="0" cellpadding="0">  
 <tr>   
 <td align="center" valign="top"><table width="100%" border="0">  
 <tr>  
 <td height="25" align="center" class="label">Import CSV Tax File </td>  
 </tr>  
 </table>  
 <table width="100%" border="0" cellpadding="3" cellspacing="0">  
 <tr>  
 <td valign="top"><form action="addbatchtext.php" method="post" enctype="multipart/form-data">  
 <table width="100%" border="1">  
 <tr>   
 <td width="30%" class="line2">File Name:</td>  
 <td width="70%" align="left" class="line2"><input name="files" type="file" class="inp"></td>  
 </tr>  
 <tr>  
 <td class="line2">&nbsp;</td>  
 <td align="left" valign="middle" class="line2">&nbsp;</td>  
 </tr>  
 <tr><td class="line2">&nbsp;</td>  
 <td align="left" valign="middle" class="line2">  
 <input name="submit" type="submit" class="buttons" value="Submit" ></td>  
 </tr>  
 </table>  
 </form></td>  
 </tr>  
 </table></td>  
 </tr>  
 </table>  
 </body>  
 </html>  

Monday, January 9, 2012

Hiding iframe border in IE

<iframe id="myiframe" name"myiframe" frameborder="0" width="900" height="600"></iframe>

Friday, January 6, 2012

Navigate rows in jqGrid (jQuery Grid)


Here's how to navigate rows in jqGrid (jQuery Grid)


function naviGrid(direct)
{
var gridArr = $('#list1').getDataIDs();                
var selrow = $('#list1').getGridParam("selrow");              
var curr_index = 0;                
for(var i = 0; i < gridArr.length; i++)                
{                    
if(gridArr[i]==selrow)                        
curr_index = i;                
}                
if(direct == 'back') //back                
{                    
if((curr_index-1)>=0)                        
$('#list1').resetSelection().setSelection(gridArr[curr_index-1],true);                
}                
if(direct == 'fwd') //forward                
{                    
if((curr_index+1)<gridArr.length)                        
$('#list1').resetSelection().setSelection(gridArr[curr_index+1],true);                
}
}

Friday, December 30, 2011

Attach database failed : "Unable to open the physical file "....". Operation system error 5: "5(Access is Denied)". Microsoft SQL Server, Error: 5120)

If you receive this follow error while you are trying to attach you old or back-up database mdf file to your Microsoft SQL Server 2008, you can fix it by using the methods mentioned below.

Attach database failed .................
"Unable to open the physical file "....". Operation system error 5: "5(Access is Denied)". Microsoft SQL Server, Error: 5120)

There are several ways of fixing it. I looked for the solutions and found these 3 methods from http://blog.sqlauthority.com. Here, I am going to re-share them again.


Method 1. ----- Tested
CREATE DATABASE ygnonline ON
(FILENAME = N'D:\MyProjects\myapps\database\mydb_Data.mdf')
FOR ATTACH_REBUILD_LOG
GO
***The log file (.ldf) will be recreated.

Method 2.

EXEC sp_attach_single_file_db @dbname='TestDb',
@physname=N'D:\MyProjects\myapps\database\mydb_Data.mdf'
GO


Method 3.

CREATE DATABASE ygnonline ON
(FILENAME = N'D:\MyProjects\myapps\database\mydb_Data.mdf')
FOR ATTACH
GO


I never try myself on method 2 and 3 since the issue I have is fixed with the method 1. Please kindly be advised to check with your database expert before using above methods in live or production environment.
You can also go and read TechNet library of Microsoft for more details in this.
Wish you guys can fix all the bugs you got before coming of the new year!!! Good Luck!! Enjoy!!! All the best!!!!!!