Codxplore.com

Latest news:

New android application Islamic Video has been released. its a free islamic video application for android smartphone. Download now!

jQuery ui date picker in Yii



We can use this piece of code for jQuery ui date picker in php Yii framework.

                $this->widget('zii.widgets.jui.CJuiDatePicker', array(
                    'model' => $model,
                    'attribute' => 'PRD_START_DT',
                    'options' => array(
                        'dateFormat' => 'd-M-y',
                        'showAnim' => 'slide',
                        'changeMonth' => true,
                        'changeYear' => true,
                        'minDate' => date('d-M-y'),
                    ),
                    'htmlOptions' => array(
                        'class' => 'form-control',
                    ),
                ));
                ?>

here,

model = is your model class

attribute = model attribute / table column name

option = contains date picker formate, animation type etc

htmlOptions = contains the id , class etc

 

thanks

 


Views: 683

Yii load data into select box from database



Add your own defined method in your model class .For Example

public function getMacList() {
        $model = POS_MAC::model()->findAll();
        $data = CHtml::listData($model, 'MID', 'MAC_ADDRESS');
        
        return $data;
}
 
and your html where you want to view the data into select box
 
echo $form->dropDownList($model, 'POS_MAC_MID',$model->getMacList(),array('class'=>'form-control'));
?>
 
here,
1st parameter is your model , 
2nd parameter is database column name or model attribute name
3rd parameter is the method which is defined in your model class
4rth parameter is html option . eg (class,id,.....)
 
thanks

Views: 693

Yii oracle database connection



Open php.ini file and find ;extension=php_oci8.dll, enable this extension by removing ; from left side for example extension=php_oci8.dll. 

restart the apache server

now open main.php file under yourproject/protected/config/main.php file,

find db = array() section and add following code

'connectionString' => 'oci:dbname=127.0.0.1:1521/XE;charset=AL32UTF8',

'username' => 'pos',

'password' => 'pos',

for example 

'db' => array(
            'connectionString' => 'oci:dbname=127.0.0.1:1521/XE;charset=AL32UTF8',
            'username' => 'pos',
            'password' => 'pos',
),
 
Thanks

Views: 765

Javascript pop up and print




Views: 622

Testing Your XAMPP Installation



Follow these steps to test your XAMPP installation by launching the Apache web server and creating a simple PHP file.

Step 1: In the XAMPP control panel, click on ‘Start’ under ‘Actions’ for the Apache module. This instructs XAMPP to start the Apache webserver.

Step 2: Open your web browser and type in: http://localhost or 127.0.0.1

Step 3: Select your language from the splash screen.

Step 4: You should see the following screen. This means you’ve successfully installed XAMPP on your computer.

 

Step 5: We will now test whether XAMPP has installed PHP successfully. To do this, fire up Notepad and type the following into a new document:

   echo ‘Hello world’;

?>

Save this file as ‘test.php’ in c:xampphtdocs (or whichever directory you installed XAMPP in).

Step 6: Navigate to localhost/test.php. You should see the “Hello World” message:

Congratulations! You have now successfully installed XAMPP


Views: 702

Understanding XAMPP Control Panel

Understanding XAMPP Control Panel



The XAMPP control panel gives you complete control over all installed XAMPP components. You can use the CP to start/stop different modules, launch the Unix shell, open Windows explorer and see all operations running in the background.

Here is a quick overview of the Control Panel. For now, you only need to know how to start and stop an Apache server.


Views: 800

Setup PHP Environment



In order to develop and run PHP Web pages three vital components need to be installed on your computer system.

  1. Web Server
  2. Database
  3. PHP Parser

We reffer xampp. XAMPP stands for Cross-Platform (X), Apache (A), MySQL (M), PHP (P) and Perl (P). It is a simple, lightweight Apache distribution that makes it extremely easy for developers to create a local web server for testing purposes. Everything you need to set up a web server – server application (Apache), database (MySQL), and scripting language (PHP) – is included in a simple extractable file. XAMPP is also cross-platform, which means it works equally well on Linux, Mac and Windows. Since most actual web server deployments use the same components as XAMPP, it makes transitioning from a local test server to a live server is extremely easy as well.

First of all download and install the xampp as you install other software :)

 


Views: 809

Working with php timezone



The DateTime class provides all the date and time handling functionality, while the DateTimeZone provides DateTime objects with all the time zone information. We just need to provide DateTimeZone with the time zone in the Area/Location format (for example, the time zone in which this server is located is America/Los_Angeles), and it will return an object representing that time zone. We can pass this to a DateTime object to convert any time into this time zone.
Here is an overview of the steps required to accomplish this:

  1. Collect the time zone from the user and store in Area/Location format
  2. Create a DateTimeZone object using the provided time zone
  3. Create a DateTime object, providing it the time in the local time zone
  4. Convert the DateTime object to the time zone created in step 1
  5. Output the time from the DateTime object


function timezonearray() {
    $zonelist = array('Kwajalein' => '(GMT-12:00) International Date Line West',
        'Pacific/Midway' => '(GMT-11:00) Midway Island',
        'Pacific/Samoa' => '(GMT-11:00) Samoa',
        'Pacific/Honolulu' => '(GMT-10:00) Hawaii',
        'America/Anchorage' => '(GMT-09:00) Alaska',
        'America/Los_Angeles' => '(GMT-08:00) Pacific Time (US & Canada)',
        'America/Tijuana' => '(GMT-08:00) Tijuana, Baja California',
        'America/Denver' => '(GMT-07:00) Mountain Time (US & Canada)',
        'America/Chihuahua' => '(GMT-07:00) Chihuahua',
        'America/Mazatlan' => '(GMT-07:00) Mazatlan',
        'America/Phoenix' => '(GMT-07:00) Arizona',
        'America/Regina' => '(GMT-06:00) Saskatchewan',
        'America/Tegucigalpa' => '(GMT-06:00) Central America',
        'America/Chicago' => '(GMT-06:00) Central Time (US & Canada)',
        'America/Mexico_City' => '(GMT-06:00) Mexico City',
        'America/Monterrey' => '(GMT-06:00) Monterrey',
        'America/New_York' => '(GMT-05:00) Eastern Time (US & Canada)',
        'America/Bogota' => '(GMT-05:00) Bogota',
        'America/Lima' => '(GMT-05:00) Lima',
        'America/Rio_Branco' => '(GMT-05:00) Rio Branco',
        'America/Indiana/Indianapolis' => '(GMT-05:00) Indiana (East)',
        'America/Caracas' => '(GMT-04:30) Caracas',
        'America/Halifax' => '(GMT-04:00) Atlantic Time (Canada)',
        'America/Manaus' => '(GMT-04:00) Manaus',
        'America/Santiago' => '(GMT-04:00) Santiago',
        'America/La_Paz' => '(GMT-04:00) La Paz',
        'America/St_Johns' => '(GMT-03:30) Newfoundland',
        'America/Argentina/Buenos_Aires' => '(GMT-03:00) Georgetown',
        'America/Sao_Paulo' => '(GMT-03:00) Brasilia',
        'America/Godthab' => '(GMT-03:00) Greenland',
        'America/Montevideo' => '(GMT-03:00) Montevideo',
        'Atlantic/South_Georgia' => '(GMT-02:00) Mid-Atlantic',
        'Atlantic/Azores' => '(GMT-01:00) Azores',
        'Atlantic/Cape_Verde' => '(GMT-01:00) Cape Verde Is.',
        'Europe/Dublin' => '(GMT) Dublin',
        'Europe/Lisbon' => '(GMT) Lisbon',
        'Europe/London' => '(GMT) London',
        'Africa/Monrovia' => '(GMT) Monrovia',
        'Atlantic/Reykjavik' => '(GMT) Reykjavik',
        'Africa/Casablanca' => '(GMT) Casablanca',
        'Europe/Belgrade' => '(GMT+01:00) Belgrade',
        'Europe/Bratislava' => '(GMT+01:00) Bratislava',
        'Europe/Budapest' => '(GMT+01:00) Budapest',
        'Europe/Ljubljana' => '(GMT+01:00) Ljubljana',
        'Europe/Prague' => '(GMT+01:00) Prague',
        'Europe/Sarajevo' => '(GMT+01:00) Sarajevo',
        'Europe/Skopje' => '(GMT+01:00) Skopje',
        'Europe/Warsaw' => '(GMT+01:00) Warsaw',
        'Europe/Zagreb' => '(GMT+01:00) Zagreb',
        'Europe/Brussels' => '(GMT+01:00) Brussels',
        'Europe/Copenhagen' => '(GMT+01:00) Copenhagen',
        'Europe/Madrid' => '(GMT+01:00) Madrid',
        'Europe/Paris' => '(GMT+01:00) Paris',
        'Africa/Algiers' => '(GMT+01:00) West Central Africa',
        'Europe/Amsterdam' => '(GMT+01:00) Amsterdam',
        'Europe/Berlin' => '(GMT+01:00) Berlin',
        'Europe/Rome' => '(GMT+01:00) Rome',
        'Europe/Stockholm' => '(GMT+01:00) Stockholm',
        'Europe/Vienna' => '(GMT+01:00) Vienna',
        'Europe/Minsk' => '(GMT+02:00) Minsk',
        'Africa/Cairo' => '(GMT+02:00) Cairo',
        'Europe/Helsinki' => '(GMT+02:00) Helsinki',
        'Europe/Riga' => '(GMT+02:00) Riga',
        'Europe/Sofia' => '(GMT+02:00) Sofia',
        'Europe/Tallinn' => '(GMT+02:00) Tallinn',
        'Europe/Vilnius' => '(GMT+02:00) Vilnius',
        'Europe/Athens' => '(GMT+02:00) Athens',
        'Europe/Bucharest' => '(GMT+02:00) Bucharest',
        'Europe/Istanbul' => '(GMT+02:00) Istanbul',
        'Asia/Jerusalem' => '(GMT+02:00) Jerusalem',
        'Asia/Amman' => '(GMT+02:00) Amman',
        'Asia/Beirut' => '(GMT+02:00) Beirut',
        'Africa/Windhoek' => '(GMT+02:00) Windhoek',
        'Africa/Harare' => '(GMT+02:00) Harare',
        'Asia/Kuwait' => '(GMT+03:00) Kuwait',
        'Asia/Riyadh' => '(GMT+03:00) Riyadh',
        'Asia/Baghdad' => '(GMT+03:00) Baghdad',
        'Africa/Nairobi' => '(GMT+03:00) Nairobi',
        'Asia/Tbilisi' => '(GMT+03:00) Tbilisi',
        'Europe/Moscow' => '(GMT+03:00) Moscow',
        'Europe/Volgograd' => '(GMT+03:00) Volgograd',
        'Asia/Tehran' => '(GMT+03:30) Tehran',
        'Asia/Muscat' => '(GMT+04:00) Muscat',
        'Asia/Baku' => '(GMT+04:00) Baku',
        'Asia/Yerevan' => '(GMT+04:00) Yerevan',
        'Asia/Yekaterinburg' => '(GMT+05:00) Ekaterinburg',
        'Asia/Karachi' => '(GMT+05:00) Karachi',
        'Asia/Tashkent' => '(GMT+05:00) Tashkent',
        'Asia/Kolkata' => '(GMT+05:30) Calcutta',
        'Asia/Colombo' => '(GMT+05:30) Sri Jayawardenepura',
        'Asia/Katmandu' => '(GMT+05:45) Kathmandu',
        'Asia/Dhaka' => '(GMT+06:00) Dhaka',
        'Asia/Almaty' => '(GMT+06:00) Almaty',
        'Asia/Novosibirsk' => '(GMT+06:00) Novosibirsk',
        'Asia/Rangoon' => '(GMT+06:30) Yangon (Rangoon)',
        'Asia/Krasnoyarsk' => '(GMT+07:00) Krasnoyarsk',
        'Asia/Bangkok' => '(GMT+07:00) Bangkok',
        'Asia/Jakarta' => '(GMT+07:00) Jakarta',
        'Asia/Brunei' => '(GMT+08:00) Beijing',
        'Asia/Chongqing' => '(GMT+08:00) Chongqing',
        'Asia/Hong_Kong' => '(GMT+08:00) Hong Kong',
        'Asia/Urumqi' => '(GMT+08:00) Urumqi',
        'Asia/Irkutsk' => '(GMT+08:00) Irkutsk',
        'Asia/Ulaanbaatar' => '(GMT+08:00) Ulaan Bataar',
        'Asia/Kuala_Lumpur' => '(GMT+08:00) Kuala Lumpur',
        'Asia/Singapore' => '(GMT+08:00) Singapore',
        'Asia/Taipei' => '(GMT+08:00) Taipei',
        'Australia/Perth' => '(GMT+08:00) Perth',
        'Asia/Seoul' => '(GMT+09:00) Seoul',
        'Asia/Tokyo' => '(GMT+09:00) Tokyo',
        'Asia/Yakutsk' => '(GMT+09:00) Yakutsk',
        'Australia/Darwin' => '(GMT+09:30) Darwin',
        'Australia/Adelaide' => '(GMT+09:30) Adelaide',
        'Australia/Canberra' => '(GMT+10:00) Canberra',
        'Australia/Melbourne' => '(GMT+10:00) Melbourne',
        'Australia/Sydney' => '(GMT+10:00) Sydney',
        'Australia/Brisbane' => '(GMT+10:00) Brisbane',
        'Australia/Hobart' => '(GMT+10:00) Hobart',
        'Asia/Vladivostok' => '(GMT+10:00) Vladivostok',
        'Pacific/Guam' => '(GMT+10:00) Guam',
        'Pacific/Port_Moresby' => '(GMT+10:00) Port Moresby',
        'Asia/Magadan' => '(GMT+11:00) Magadan',
        'Pacific/Fiji' => '(GMT+12:00) Fiji',
        'Asia/Kamchatka' => '(GMT+12:00) Kamchatka',
        'Pacific/Auckland' => '(GMT+12:00) Auckland',
        'Pacific/Tongatapu' => '(GMT+13:00) Nukualofa'
    );

    return $zonelist;
}

function getSiteTime($timestamp="") {

     $dtzone = new DateTimeZone($selectedTimezone);

    $time = date('r', $timestamp);

    $dtime = new DateTime($time);

    $dtime->setTimeZone($dtzone);

    $time = $dtime->format('m-d-Y, a\t g.i A');

    return $time;
}

?>

The Time :
Thats it


Views: 860

Magento installation Invalid Base URL



I was installing magento on localhost so i can test different magento extensions.
But on configuration page I was getting error for base url as below:
The URL "http://www.magento.ag.com/" is invalid.
Response from server isn't valid.
The URL "http://www.magento.local/" is invalid.
Response from server isn't valid.
The URL "http://localhost/" is invalid.
Response from server isn't valid.
Note: I was trying with different urls but all failed. At last found one solution.
Update this file: app/code/core/Mage/Install/Model/Installer/config php

replace line:

$prefix = $secure ? 'install/wizard/checkSecureHost/' : 'install/wizard/checkHost/';

with

$prefix = $secure ? 'index.php/install/wizard/checkSecureHost/' : 'index.php/install/wizard/checkHost/';

or replace line:

$client = new Varien_Http_Client($url.$prefix);

with

$client = new Varien_Http_Client($url.'index.php/'.$prefix);



NOTE: newer versions of magentos already got this fix but still I was getting same error.

Finally, the live saver trick was to check the checkbox of option:
=> Skip Base URL Validation Before the Next Step

Then, everything worked as I wanted.


Views: 920

MD5 encryption using java



package yourpackage;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/**
 *
 *
 */
public class Encrypt {
    
    public static String md5(String input) {

        String md5 = null;

        if (null == input) {
            return null;
        }

        try {

            //Create MessageDigest object for MD5
            MessageDigest digest = MessageDigest.getInstance("MD5");

            //Update input string in message digest
            digest.update(input.getBytes(), 0, input.length());

            //Converts message digest value in base 16 (hex)
            md5 = new BigInteger(1, digest.digest()).toString(16);

        } catch (NoSuchAlgorithmException e) {

            e.printStackTrace();
        }
        return md5;
    }
}


Views: 703

MySQL database connection using java



Right Click on the libraries  under your projec propertise , now click on the Add jar/folder

now add the mysql-connector-java-5.1.23-bin.jar

now add the following class to your project 

package yourpackagename;

import java.sql.*;

/**
 *
 *
 */
public class DB {

    Connection con = null;
    Statement st = null;
    ResultSet rs = null;
    ResultSetMetaData md = null;
    String dburl = "jdbc:mysql://localhost:3306/addressBook";
    String dbuser = "root";
    String dbpassword = "";

    public DB() {
        try {
            con = DriverManager.getConnection(dburl, dbuser, dbpassword);
            st = con.createStatement();
        } catch (Exception ex) {
            ex.getMessage();
        }
    }
}


Views: 706

How to connect mysql database using php



$con = mysql_connect('localhost','root','');
if(!$con){
    mysql_error('Could not connect');
}else{
     mysql_select_db('spa_db',$con);
     //echo 'success';
    }
?>


Views: 684

Subscribe Us


Follow Us