Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts

Tuesday, May 1, 2018

PHP Oracle Database connection in Xamp

If you installed xamp for php programing and want to connect Oracle database as backend then you have to enable this. By default we did not get php oracle enabled.
PHP has OCI8 extention, which provide oracle connectivity to php application. OCI8 uses "oracle Instant Client" Package to get oracle specific function.

1. Download the "Instant client Package-Basic" for windows  from the OTN instant client page.



2. Unzip it to c:\instantClient_11_2

3. Now need to edit  System "Environment Variables". For this go to My computer property click on "Advance System Setting" and then Environment Variables. and add "C:\instantclient_11_2" to system variable PATH.


4. Restart Your computer.

5. Now find the below string in php.ini file.
;extension=php_oci8.dll
;extension=php_oci8_11.dll

remove semicolon( ;) to uncomment string.

6. Now Download the Actual Thread safe OCI-DLL from  https://pecl.php.net/package/oci8/2.0.8/windows
Download according to you php version. suppose your php version is 5.4, then download 5.4 Thread safe(TS) x86 zip file.


7. unzip OCI-DLL zip and and copy all files from this folder to Extention Directory of PHP C:\xampp\php\ext

8. Restart xamp Appache server.

9. To make sure that the connection to oracle database is successfully activated, go to phpinfo (http://localhost/dashboard/phpinfo.php). find string 'oci8' .If found, then xamp can communicate from Oracle database
Now we check connection using below PHP script :

<?php

$DB ="(DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.0.3)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = SERVICE_NAME)
    )
  )";
$conn=oci_connect('USERID','PASSWORD',$DB);

if(!$conn)
{
die('Could not connect: ' . oci_error());
}
else
{
 echo "Successfully";
}

?>


Sunday, October 5, 2014

PHP Fatal error: Call to undefined function session_register()

session_register() has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0.

Your facing this problem because of you are using PHP 5.4.0 or above

Read PHP documentation
http://www.php.net/manual/en/function.session-register.php


For solution : Remove  session_register() from you code.

Saturday, June 28, 2014

India date and time in php

India date & time can get by setting indian zone and using date function of php. Use Below code

<?php

date_default_timezone_set('Asia/Calcutta');
echo date("H:i");
echo date("d-M-Y");

?>

Friday, June 27, 2014

How to get two date which in varchar type is equal are not in PHP

Suppose we have two date field or two date from SQL result and we want to find out if the eual or not, then you can try below cod code
if ( strtotime($date1) == strtotime($date2) )
{
 echo "date is equal";
}