Category: PHP

Compile individual php module

Compile individual php module

You  need to have a package phpize in order to compile an additional module. If you dont have phpize,  you need to install php-devel . When you install php from source.. you should get...

php preg match

php preg match

<?php function isDigits($element) { //numbers only return !preg_match (“/[^0-9]/”, $element); } ?> <?php function Dollars($element) { //numbers and decimal return !preg_match (“/[^0-9.]/”, $element); } ?> <?php function isLetters($element) { //letters only return !preg_match (“/[^A-z]/”,...

Export CSV Php

Export CSV Php

$result= mysql_query(“sql query”); if(mysql_num_rows($result)> 0) { $num_fields=mysql_num_fields($result); $headers = array(“Col1 Name”,”Col2 Name”,”Col3 Name”); $fp = fopen(‘php://output’, ‘w’); if ($fp && $result) { header(‘Content-Type: text/csv’); header(‘Content-Disposition: attachment; filename=”export.csv”‘); header(‘Pragma: no-cache’); header(‘Expires: 0’); fputcsv($fp, $headers); while...

Installing A Custom Repo

Installing A Custom Repo

To install PHP 5.2.5 which is the latest version in the repos  you can make use of a RPM repository maintained by Remi. He has a repository for many distros. Follow  the steps to...

Accessing Microsoft SQL Database from Linux Boxes

Accessing Microsoft SQL Database from Linux Boxes

In order to use Linux & MSSQL with php , we need to install a TDS driver which is Tabular Data Stream Protocol. yum install freetds /usr/bin/tsql -S [mssql server name or ip] -U...

Import CSV file to database using PHP

Import CSV file to database using PHP

Below is the code snippet that will let you import CSV file into database using PHP : <?php # first get a mysql connection as per the FAQ $fcontents = file (‘./spreadsheet.xls’); # expects...