Connecting PHP to MYSQL Database in another machine

If you had webserver and you had another mysql that hosting your database, and it is kept in another machine and you want to connect it via your local area network, so you need to grant access for remote connection on that mysql.

Please run the following script on SQL command at that mysql database :

                ‘[user]’@'[hostname]’ identified by

Note : replace [dbname] with your database name, replace [user] with your username or you can put root as default, replace [hostname] with your computer IP/name that act as your webserver, and replace [password]  with your password that set at the beginning.

For doing some testing, you can try the following command (command prompt) at your computer that act as webserver :

telnet 3306 <enter>

Note : if you don’t see the message that the computer (hosted mysql database)  refuse your connection directly, it means your connection to that mysql database can be established.


Show PDF file in PHP

If you want to show your PDF file in PHP, you can put the code as follow :



header(‘Content-type: application/pdf’);

header(‘Content-Disposition: attachment; filename=”‘.pdf.'”‘);



Note : The above code will open/ save PDF file as attachment. If you want to show the PDF file directly into same window, you can change the Content-disposition type into inline. So, the line

header(‘Content-Disposition: attachment; filename=”‘.pdf.'”‘);” should be change into :

header(‘Content-Disposition: inline; filename=”‘.pdf.'”‘);


There is many option can be used for header field in PHP. For complete reference, you can follow this link :

Hope this article can be useful.