RSS

Monthly Archives: March 2012

[joomla][tip] DB connection in non joomla pages

While using ajax based dropdowns, I required a db connection in php page (non joomla page). I did it as follows:

include(“../../../../configuration.php”); //adjust the path of configuration.php
$config = new JConfig();
$con = mysql_connect($config->host,$config->user,$config->password);
mysql_select_db($config->db,$con);

And Thats it 🙂

Same goes with almost every cms and framework.

Advertisements
 
Leave a comment

Posted by on March 22, 2012 in joomla

 

Tags: , , ,

[php][quick tutorial] Popup for downloading txt file instead of opening it in browser

Here is a simple code for getting the popup for downloading a txt file (or any other file which get opened in the browser).

print file_get_contents(“test_content.txt”);
header(‘Content-Disposition: attachment; filename=”test_download.txt”‘);

line 1, prints the text file content which is to be downloaded.

line 2, make the printed content of the page to be downloaded by showing a popup first.

Note: whatever html and php code is printed in the page will be a part of test_download.txt file content.

Have a nice php ahead 🙂

 
Leave a comment

Posted by on March 19, 2012 in Uncategorized

 

Tags: , , , , , ,

 
%d bloggers like this: