Friday, June 18, 2010

Excel SpreadSheet to PHP converter

Hi, it's been too long since the last time I post in here.
So, i have something new for you. It is the Excel PHP parser.
In this script you can parse/extract the data coming from a spreadsheet file.
Example of spreadsheet file is well known microsoft excel.
Download the script here

Hope this helps!

Thursday, April 8, 2010

Simple htaccess script that will make your website's url look good

1. How to redirect your website to non-www to www.

RewriteEngine On
RewriteBase /RewriteCond %{HTTP_HOST} ^yoursite\.com [NC]
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [R=301,L]

Copy the code into your htaccess file and don't forget to change"yoursite" with your website name

2. How to create an htaccess script that would allow you to customize your website url

here is a sample:

RewriteEngine On
RewriteBase /RewriteCond %{HTTP_HOST} ^yoursite\.com [NC]
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [R=301,L]
RewriteRule ^news/([^/]+)/([^/]+)/([^/]+)/([^/]+).html permapages.php?year=$1&month=$2&day=$3&title=$4 [NC]

for example, you have this url http://www.yoursite.com/news/2010/2/2/testing.html.
This url will point to "permapages.php" based on what we declared in our htaccess and the
"([^/]+)/([^/]+)/([^/]+)/([^/]+)" are the parameters that we passed along with the script.
So if you are going to print the $_GET values inside permapages.php you will get something like this

array( year=>2010, month=>2, day=>2, title=>testing)

You can now add codes in your permapages.php to display contents that you want to put in http://www.yoursite.com/news/2010/2/2/testing.html.

note: put permapages.php in root folder of your site
This is it. Hope it helps.

Tuesday, February 23, 2010

How to fix jos_session problem in Joomla


ON the Run SQL query/queries on database Copy and paste this code and click Go


DROP TABLE IF EXISTS `jos_session`;
CREATE TABLE IF NOT EXISTS `jos_session` (
`username` varchar(50) default '',
`time` varchar(14) default '',
`session_id` varchar(200) NOT NULL default '0',
`guest` tinyint(4) default '1',
`userid` int(11) default '0',
`usertype` varchar(50) default '',
`gid` tinyint(3) unsigned NOT NULL default '0',
PRIMARY KEY (`session_id`),
KEY `whosonline` (`guest`,`usertype`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


So this sql query will drop the existing jos_session which is using an engine MEMORY
and create a new one with an engine MyISAM. Engine Memory may either good for fast retreival
of data but really consumes much memory in DB. So instead of using engine MEMORY for jos_session
table, we changed it to MyIsam. Well it works great for me. ;)

Monday, February 22, 2010

how to remove "Joomla SEF URLs by Artio" in artio joomsef version 3.5.5


To remove "Joomla SEF URLs by Artio" in your page, download this necessary file using ftp

/components/com_sef/joomsef.php

then use an editor to open the file then comment line 1771 and 1772

line 1771 and 1772 looks like this

if (JRequest::$cosi('fo'.'rmat') != 'r'.'aw')
$doc->$cache($cacheBuf . base64_decode($cacheBuf2), 'component');


So this will look like this now

/*

if (JRequest::$cosi('fo'.'rmat') != 'r'.'aw')
$doc->$cache($cacheBuf . base64_decode($cacheBuf2), 'component');
*/


or


// if (JRequest::$cosi('fo'.'rmat') != 'r'.'aw')
// $doc->$cache($cacheBuf . base64_decode($cacheBuf2), 'component');


So, what joomsef did is, they encoded the link into base 64 format then decoded
it when displayed in the page.


so this is it! Good luck.

Tuesday, December 8, 2009

how to insert uft8 data in a latin1 structure tables/DB

I have been so problematic these past few days with a mysql insertion problem.Every time when i tried to insert a text that contains "‘" left single quote, "’" right single quote, "“" left double quote and "”" right double quote or what they call it a prime or anything that is to be treated as a html special character when i look the data in the Database they will be transformed into a strange characters that contains euro "€", i don't know why.

When i'm going to retrieve those data, they will be display the same strange characters that are in DB.
I think there is a problem with the structure of our DB. The collation type of every table of our
Database is "latin1_swedish_ci".

They say that we need to transform the collation type of our DB to "utf8_general_ci" in order to
overcome this problem. But sad to say, its no used. It is still the same.
I have been searching and searching for answers in days, just to find out how to solve this problem.
At last, after a days of searching i found the solution.

If you are also experiencing something like this, here is the solution.

In your mysql insertion query like "INSERT INTO example (name, age) VALUES ('Timmy Mellowman', '23' )"
add "_utf8" before the inserted data to any text/varchar/char DB datatype that you want to fix.

It should look like this now "INSERT INTO example (name, age) VALUES (_utf8'Timmy Mellowman', '23' )".

"_utf8" => This function will convert text in utf8 format so that when you retrieve those saved
data, you will not be seeing anymore strange characters that contains euro "€".

But wait, when you retrieved the data from DB and if you will going to see "?" question marks instead of html special characters. You need to execute this query "set names utf8" before displaying the query results.


mysql_query("SET names utf8");
$result = mysql_query("select * from example");

Now, this will fix the problem.

Sunday, November 15, 2009

fetching a website using curl function in php

<?

// initialize curl
$ch = curl_init();

// set the URL and other option
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");
curl_setopt($ch, CURLOPT_HEADER, 0);

// get the URL and pass it to the browser
curl_exec($ch);

// close the initialized curl
curl_close($ch);
?>

Tuesday, October 20, 2009

What is the recommended upload_max_filesize, post_max_size, and memory_limit?

Hey Guyz, do you wanna know what is the recommended upload_max_filesize, post_max_size, and memory_limit?

For me, as a php programmer for more than a year it depends on how much you need it. for example if you are going to upload a filesize of 50MB,then you can set the uploading configuration that would meet your needs.

In default, your uploading configuration is set to these values:

Maximum file size: 2MB
post_max_size: 8MB
memory_limit: 16MB

Meaning, it only allows you to upload 2MB (Maximum file size: 2MB) of file. I also wrote an article before on how to increase your upload_max_filesize, post_max_size, and memory_limit without accessing php.ini, that is incase you don't have access to it.

take note of this:
post_max_size > upload_max_filesize
post_max_size < memory_limit