My experience on my daily works... helping others ease each other

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

Thursday, September 27, 2018

Writing API using Native API

There are many tools/framework you can use without even need to write code such as strapi, LoopBack, Fusio, Api Umbrella, Kong, etc. If you need to develop it fast and run nginx or nodejs behind, utilizing and highly dependent on the available method and don't want to think or dirty your hand, then, either one of the above lists shall be sufficient.

However, if you need to run complex query upon request, despite all of the API framework/tool allowed you to perform that, but it does not guarantee great flexibility and stability when the framework/tool is updated.

There is a way to handle and overcome the limitation. I'm using native PHP to provide a complex query and processing API.

Feel free to check the code and try it out at github.
Share:

Tuesday, February 28, 2017

PHP Randomize and Sort for multi-dimensional array

Learn to use rand() in php and sortation on multi-dimensional array via dice program.

Here is the code https://github.com/masteramuk/PHP-Rand-and-Sort
Share:

Tuesday, December 20, 2016

json_decode(file_get_contents("php://input") on https

When you try to run json_decode on https, it will throw errors due to null value. file_get_contents("php://input") will also return null.

Way to solve it and the most efficient are as follows

//get data from caller
$arrContextOptions=array(
 "ssl"=>array(
"verify_peer"=>false,
"verify_peer_name"=>false,
),
);  
$your_data_array= json_decode(file_get_contents("php://input",false, stream_context_create($arrContextOptions)),true);

The code actually make it don't care what protocol you are using and set it to false (means no verifications). It normally happen when you are using self-signed or non-standard SSL certificates.

It is the most efficient and the fastest solutions.. but not the most practical :)

The best is -> use standard approved certificates :)
Share:

Sunday, September 27, 2015

Don't post your log on screen @ web page

Programmers love to display log on their working page while developing the page. And normally, when they release the page or site, there are always pages that they forgot to disable of remove the log. When this happen, they are actually opening a small window to cyber threat @ hackers.

Take for example or a website below (click to enlarge)

The site show the IP address, the type of database and the path use for the database connection. Now, this may be good for programmer, but it is security loopholes that shall and can be easily avoided.

As an advice to programmers, if you need to log, PLEASE do log on a file which shall be truncated/replace (configured) not more than a week.

p/s: I'm also programmer with security interest :)
Share:

Monday, March 30, 2015

Accessing MSSQL with PHP - Solving Microsoft ODBC Driver Problem

I'm using PHP 5.6.3 with XAMPP (installed using xampp-win32-5.6.3-0-VC11-installer.exe). When trying to connect to MSSQL server database, it trigger error as below (or almost the same error).

Array ( [0] => Array ( [0] => IMSSP [SQLSTATE] => IMSSP [1] => -49 [code] => -49 [2] => This extension requires the Microsoft ODBC Driver 11 for SQL Server....

This error occur after the XAMPP started with sqlserver extension defined in PHP.ini successfully loaded.

Looking at PHP manual @ http://php.net/manual/en/function.sqlsrv-connect.php only shows how to connect. A few more site shares the same things too:

  1. https://support.winhost.com/kb/a687/sample-code-to-connect-to-an-ms-sql-database-using-php.aspx
  2. http://www.experts-exchange.com/Programming/Languages/Scripting/PHP/Q_28215738.html
  3. http://www.yiiframework.com/forum/index.php/topic/44474-sqlsrv-connection-fails-to-open/
  4. https://social.msdn.microsoft.com/Forums/sqlserver/en-us/home?forum=sqldriverforphp&sort=lastpostdesc&brandIgnore=true&page=3


Even going to Microsoft MSDN won't help that much.

So, I would like to share the step that you should take if you found or getting the same error:
  1. Go to vimalakanchanamsc.wordpress.com will share the necessary steps and it is really good if you could start from this point forward.
  2. Then, download Microsoft ODBC Driver 11 from Microsoft. Please make sure you select the correct SQL Server version. I'm using SQL Server 2014 and therefore is using the driver from that link. You may used different version of ODBC driver. It also dependent on OS architecture (x86 or x64).
  3. Upon complete this two steps, you should already have 
    • SQLSRV32.exe or SQLSRV30.exe
    • vcredist_x64.exe or vcredist_x86.exe
    • sqlncli.msi
    • msodbcsql.msi
  4. Installed one by one according to the list (from top to bottom). If you already installed, please ignore the file.


My problem of connecting the SQLSERVER in PHP resolved after I've installed all file.

That's all...

Happy PHPing


Share:

Tuesday, November 2, 2010

6th Annual Zend/PHP Conference

PHDear PHPeople,
MIMOS PHP Centre of Excellence, Enterprise PHP Center and also PHP Indonesia and Malaysia will do a live coverage of 6th Annual Zend/PHP Conference from Santa Clara Convention Center, which is going to be held at the heart of Silicon Valley, United States until 4 November 2010. 

Kindly check out the attached links for more updates such as Live Blogging, Video Coverage, Interviews and Testimonials from world's top PHP Ninja Master.

Follow twitter hashtags #zc10 #ephpc #zendcon #phpcoe for real time and interactive updates

Happy PHP'ing
--------------
PHP Malaysia, PHP Indonesia, MIMOS PHPCOE & Enterprise PHP Center Team
Enterprise PHP Center Portal -- LIVE ZendCon2010 Chatroom
http://www.enterprisephpcenter.com/chatroom/
PHP Centre of Excellence
http://phpcoe.mimos.my
Enterprise PHP Center Portal
http://www.enterprisephpcenter.com/
PHP Community, Malaysia
http://www.php.net.my
Share:

About Me

Somewhere, Selangor, Malaysia
An IT by profession, a beginner in photography

Labels

Blog Archive

Blogger templates