My Code book

Posts Tagged ‘PHP

Run Php code in html files.

Posted by: Purab on: December 23, 2009

Just use following code in your .htaccess file or apache configration file.
AddType application/x-httpd-php .html
Or for .htm
AddType application/x-httpd-php .htm
I found following article useful.
http://php.about.com/od/advancedphp/p/html_php.htm

Tags: ,

solved – bash: phpize: command not found

Posted by: Purab on: November 9, 2009

This error is due to “phpize” command not available on your server.
To fix, install php-devel package.
If your server have yum (Eg: Fedora)
[root@localhost purab]# phpize
bash: phpize: command not found
[root@localhost purab]# yum -y install php-devel
[root@localhost purab]# phpize
Cannot find config.m4.
Make sure that you run ‘/usr/bin/phpize’ in the top level source directory of the module
[root@localhost purab]#
How to install the [...]

Tags:

Use following commands:
[root@localhost ]# which php
/usr/bin/php
[root@localhost ]# which ruby
/usr/bin/ruby
[root@localhost ]# php –version
PHP 5.2.9 (cli) (built: Apr 17 2009 03:42:25)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
with eAccelerator v0.9.5.2, Copyright (c) 2004-2006 eAccelerator, by eAccelerator
[root@localhost ]# ruby –version
ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-linux]
[root@localhost Desktop]#

Tags: , , ,

Create XML through php and mysql

Posted by: Purab on: October 8, 2009

Here I am giving you the very basic sample code for creating the XML file through PHP and MYsql
<?php
// We'll be outputting a PDF
header('Content-type: text/xml');
echo "”
$db_name = “testDB”;
$connection = mysql_connect(“example.com”, “username”, “password”) or die(“Could not connect.”);
$table_name = ‘user’;
$query = “select * from ” . $table_name;
$result = mysql_query($query, $connection) or die(“Could not complete database query”);
$num = [...]

Tags: ,

PHP if else statement- Normal and advanced

Posted by: Purab on: October 6, 2009

Here now I am giving you the normal code example.
$test = 100;
if ( $test == 100 ) {
echo “The if statement evaluated to true”;
} else {
echo “The if statement evaluated to false”;
}
If you want to use this in one line than use following code:
echo $testprint = ( $test == 100 ) ?  “The if statement [...]

Tags: ,

Add This page

Bookmark and Share

Blog Stats

  • 13,797 hits

Purab’s Twittes